Commit graph

413 commits

Author SHA1 Message Date
Paul Gauthier
f026f1eeeb sniff when GPT mentions files that are not in the chat, prompt the user to add them 2023-05-10 22:05:00 -07:00
Paul Gauthier
65436ae255 refactor send output code 2023-05-10 21:42:22 -07:00
Paul Gauthier
84776593d3 black config 2023-05-10 21:35:10 -07:00
Paul Gauthier
36fe08ae13 fixed regex; black config 2023-05-10 21:32:23 -07:00
Paul Gauthier
a73ad25c55 fix 2023-05-10 21:20:04 -07:00
Paul Gauthier
22b151fdd0 aider: Added try-except block to handle ClassNotFound exception in guess_lexer_for_filename function.
# Context:
USER: Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/gauthier/Projects/aider/aider/main.py", line 74, in <module>
    status = main()
             ^^^^^^
  File "/Users/gauthier/Projects/aider/aider/main.py", line 70, in main
    coder.run()
  File "/Users/gauthier/Projects/aider/aider/coder.py", line 185, in run
    self.run_loop()
  File "/Users/gauthier/Projects/aider/aider/coder.py", line 200, in run_loop
    inp = get_input(self.history_file, self.abs_fnames, self.commands)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gauthier/Projects/aider/aider/getinput.py", line 92, in get_input
    completer_instance = FileContentCompleter(fnames, commands)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gauthier/Projects/aider/aider/getinput.py", line 24, in __init__
    lexer = guess_lexer_for_filename(fname, content)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gauthier/Projects/aider/.venv/lib/python3.11/site-packages/pygments/lexers/__init__.py", line 282, in guess_lexer_for_filename
    raise ClassNotFound('no lexer for filename %r found' % fn)
pygments.util.ClassNotFound: no lexer for filename '.flake8' found

ASSISTANT: It seems that the `guess_lexer_for_filename` function from Pygments is raising a `ClassNotFound` exception because it cannot find a lexer for the '.flake8' file. To fix this issue, you can add a try-except block around the `guess_lexer_for_filename` function call to handle the exception and continue processing other files.

Here's the change you need to make in the `aider/getinput.py` file:

```python
aider/getinput.py
<<<<<<< ORIGINAL
            lexer = guess_lexer_for_filename(fname, content)
=======
            try:
                lexer = guess_lexer_for_filename(fname, content)
            except ClassNotFound:
                continue
>>>>>>> UPDATED
```

This change will catch the `ClassNotFound` exception and continue processing the remaining files without raising an error.
2023-05-10 21:19:03 -07:00
Paul Gauthier
a4c58cf106 aider: Updated regex pattern to recognize file paths that start with a dot.
# Context:
USER: the file path part of the regex is not recognizing files that start with a . like .bash_history
ASSISTANT: I see. I'll update the regex pattern in `aider/coder.py` to recognize file paths that start with a dot (e.g., `.bash_history`). Here are the changes:

```python
aider/coder.py
<<<<<<< ORIGINAL
        r"^((?:[a-zA-Z]:\\|/)?(?:[\w\s.-]+[\\/])*\w+(\.[\w\s.-]+)*)"
=======
        r"^((?:[a-zA-Z]:\\|/)?(?:[\w\s.-]+[\\/])*(?:\w+|\.\w+)(\.[\w\s.-]+)*)"
>>>>>>> UPDATED
```

This update should now correctly recognize file paths that start with a dot.
2023-05-10 21:17:45 -07:00
Paul Gauthier
aca96263d8 aider: Added comments to the regex pattern in aider/coder.py to make it clearer.
# Context:
USER: can you modify the code to add your earlier regex comments?
ASSISTANT: Sure, I will add comments to the regex pattern in the `aider/coder.py` file to make it clearer. Here are the changes:

```python
aider/coder.py
<<<<<<< ORIGINAL
    pattern = re.compile(
        r"(^```\S*\s*)?^((?:[a-zA-Z]:\\|/)?(?:[\w\s.-]+[\\/])*\w+(\.[\w\s.-]+)*)\s+(^```\S*\s*)?^<<<<<<< ORIGINAL\n(.*?\n?)^=======\n(.*?)^>>>>>>> UPDATED",  # noqa: E501
        re.MULTILINE | re.DOTALL,
    )
=======
    pattern = re.compile(
        # Optional: Matches the start of a code block (e.g., ```python) and any following whitespace
        r"(^```\S*\s*)?"
        # Matches the file path
        r"^((?:[a-zA-Z]:\\|/)?(?:[\w\s.-]+[\\/])*\w+(\.[\w\s.-]+)*)"
        # Optional: Matches the end of a code block (e.g., ```) and any following whitespace
        r"\s+(^```\S*\s*)?"
        # Matches the start of the ORIGINAL section and captures its content
        r"^<<<<<<< ORIGINAL\n(.*?\n?)"
        # Matches the separator between ORIGINAL and UPDATED sections and captures the UPDATED content
        r"^=======\n(.*?)"
        # Matches the end of the UPDATED section
        r"^>>>>>>> UPDATED",
        re.MULTILINE | re.DOTALL,
    )
>>>>>>> UPDATED
```

This should make the regex pattern more understandable.
2023-05-10 21:16:22 -07:00
Paul Gauthier
f26a215ff4 bugfix 2023-05-10 21:13:23 -07:00
Paul Gauthier
d1c62ce09f lint 2023-05-10 20:04:56 -07:00
Paul Gauthier
6fe656c093 removed 2023-05-10 20:03:30 -07:00
Paul Gauthier
4b02f040b0 fixed indent 2023-05-10 19:56:32 -07:00
Paul Gauthier
d0222a7129 color edits 2023-05-10 19:55:59 -07:00
Paul Gauthier
c9efc43c98 aider: Added pyproject.toml file to configure black to use a maximum line length of 100 characters.
# Context:
USER: can i tell black to fix these automatically?
ASSISTANT: Yes, you can use the `black` code formatter to automatically fix formatting issues in your Python files. To do this, you need to have `black` installed. If you don't have it installed, you can install it using pip:

```
pip install black
```

Once `black` is installed, you can run it on a specific file or directory to automatically format the code:

```
black aider/coder.py
```

This command will format the `aider/coder.py` file according to the `black` code style. If you want to format all the Python files in your project, you can run `black` on the project directory:

```
black .
```

This command will format all the Python files in the current directory and its subdirectories.
USER: Please note that I shared content of these additional files: .pre-commit-config.yaml
ASSISTANT: Yes, I see the content of the .pre-commit-config.yaml file. It shows that you have already configured pre-commit hooks for `black` and `flake8`.

When you commit your changes, the pre-commit hooks will automatically run `black` to format your code and `flake8` to check for any linting issues. If there are any issues, the commit will be blocked, and you'll need to fix them before committing again.

To run the pre-commit hooks manually without committing, you can use the following command:

```
pre-commit run --all-files
```

This command will run all the configured hooks on all the files in your repository. If there
^C KeyboardInterrupt
USER: can we configure black to shorten lines to less than 100 chars so flake8 doesn't complain about E501
ASSISTANT: Yes, you can configure `black` to use a specific line length by adding a `pyproject.toml` file to your project's root directory with the desired line length setting. Here's how to create and configure the `pyproject.toml` file:

```toml
pyproject.toml
<<<<<<< ORIGINAL
=======
[tool.black]
line-length = 100
>>>>>>> UPDATED
```

This configuration sets the maximum line length for `black` to 100 characters, which will match the line length requirement of `flake8`. After adding this configuration, `black` will automatically format your code to keep lines within the specified limit.
2023-05-10 19:54:45 -07:00
Paul Gauthier
ff62734fa1 aider: Fixed line length issue by splitting a long line into two lines.
# Context:
USER: aider/commands.py:155:101: E501 line too long (117 > 100 characters)

ASSISTANT: To fix the line length issue, you can split the long line into multiple lines. Here's the change:

```python
aider/commands.py
<<<<<<< ORIGINAL
        if not matched_files:
            if self.coder.repo is not None:
                create_file = Confirm.ask(
                    f"[bright_black]No files matched '{word}'. Do you want to create the file and add it to git?"
                )
=======
        if not matched_files:
            if self.coder.repo is not None:
                create_file = Confirm.ask(
                    f"[bright_black]No files matched '{word}'. "
                    "Do you want to create the file and add it to git?"
                )
>>>>>>> UPDATED
```

This change splits the long line into two lines, keeping the code within the 100 characters limit.
2023-05-10 19:51:25 -07:00
Paul Gauthier
a4398dc503 aider: Removed unused 'new_file' variable in aider/commands.py.
# Context:
USER: Please note that I shared content of these additional files: aider/commands.py
ASSISTANT: Yes, I see the content of aider/commands.py. The issue mentioned earlier is about the local variable 'new_file' being assigned but never used. To fix this, you can remove the 'new_file' variable and use a 'pass' statement instead. Here's the change:

```python
aider/commands.py
<<<<<<< ORIGINAL
                    with open(os.path.join(self.coder.root, word), "w") as new_file:
                        pass
=======
                    with open(os.path.join(self.coder.root, word), "w"):
                        pass
>>>>>>> UPDATED
```

This change removes the unused 'new_file' variable while keeping the file creation functionality intact.
2023-05-10 19:50:34 -07:00
Paul Gauthier
8abf56ae94 change most aider messages to bright_black instead of red; use that for errors 2023-05-10 19:49:26 -07:00
Paul Gauthier
f7b58b780b Changed prompt message for creating a file when no files matched the search term. 2023-05-10 19:41:30 -07:00
Paul Gauthier
296053a8d7 aider: Added commit message to cmd_add method to indicate that the file was created and added by the aider.
# Context:
USER: also commit the add with a suitable message
ASSISTANT: To commit the added file with a suitable message, we will modify the `cmd_add` method in the `aider/commands.py` file. After adding the file to git, we will commit it with a message indicating that the file was created and added by the aider.

Here are the changes to the `aider/commands.py` file:

```python
aider/commands.py
<<<<<<< ORIGINAL
                    if self.coder.repo is not None:
                        self.coder.repo.git.add(os.path.join(self.coder.root, word))
=======
                    if self.coder.repo is not None:
                        self.coder.repo.git.add(os.path.join(self.coder.root, word))
                        commit_message = f"aider: Created and added {word} to git."
                        self.coder.repo.git.commit("-m", commit_message, "--no-verify")
>>>>>>> UPDATED
```

These changes commit the added file with a message indicating that the file was created and added by the aider.
2023-05-10 19:40:35 -07:00
Paul Gauthier
c6d388595d aider: Added ability to create and add file to git if coder repo is not None.
# Context:
USER: say "do you want to create the file and add it to git?" if self.coder.repo is not none. and then add it to git.
ASSISTANT: To implement this feature, we will modify the `cmd_add` method in the `aider/commands.py` file. We will check if `self.coder.repo` is not `None` and then ask the user if they want to create the file and add it to git. If the user confirms, we will create the file, add it to `matched_files`, and add it to the git repository.

Here are the changes to the `aider/commands.py` file:

```python
aider/commands.py
<<<<<<< ORIGINAL
                create_file = Confirm.ask(f"No files matched '{word}'. Do you want to create the file?")
                if create_file:
                    with open(os.path.join(self.coder.root, word), 'w') as new_file:
                        pass
                    matched_files = [word]
=======
                if self.coder.repo is not None:
                    create_file = Confirm.ask(f"No files matched '{word}'. Do you want to create the file and add it to git?")
                else:
                    create_file = Confirm.ask(f"No files matched '{word}'. Do you want to create the file?")

                if create_file:
                    with open(os.path.join(self.coder.root, word), 'w') as new_file:
                        pass
                    matched_files = [word]
                    if self.coder.repo is not None:
                        self.coder.repo.git.add(os.path.join(self.coder.root, word))
>>>>>>> UPDATED
```

These changes check if `self.coder.repo` is not `None` and modify the question asked to the user accordingly. If the user confirms, the new file is created, added to `matched_files`, and added to the git repository if `self.coder.repo` is not `None`.
2023-05-10 19:39:52 -07:00
Paul Gauthier
42d48bcf35 aider: Added functionality to ask the user if they want to create a new file when no matching files are found.
# Context:
USER: Please note that I shared content of these additional files: aider/commands.py
ASSISTANT: Yes, I see the content of the `aider/commands.py` file. If you need any changes or improvements to the code, please let me know.
USER: in cmd_add if word matches no files, use Confirm.ask to ask the user if they would like to create the file. If so, touch the file and put it into matched_files so the for loop adds it
ASSISTANT: To implement this feature, we will use `Confirm.ask` from the `prompt_toolkit` library to ask the user if they want to create the file. If the user confirms, we will create the file using `open` with the 'w' flag and add it to `matched_files` so that it gets added in the for loop.

Here are the changes to the `aider/commands.py` file:

```python
aider/commands.py
<<<<<<< ORIGINAL
from prompt_toolkit.completion import Completion
from aider import prompts
=======
from prompt_toolkit.completion import Completion
from prompt_toolkit.shortcuts import Confirm
from aider import prompts
>>>>>>> UPDATED

aider/commands.py
<<<<<<< ORIGINAL
        for word in args.split():
            matched_files = [file for file in files if word in file]
            if not matched_files:
                self.console.print(f"[red]No files matched '{word}'")
=======
        for word in args.split():
            matched_files = [file for file in files if word in file]
            if not matched_files:
                create_file = Confirm.ask(f"No files matched '{word}'. Do you want to create
^C KeyboardInterrupt
USER: in cmd_add if word matches no files, use rich.prompt.Confirm.ask to ask the user if they would like to create the file. If so, touch the file and put it into matched_files so the for loop adds it
ASSISTANT: To implement this feature, we will use `Confirm.ask` from the `rich.prompt` library to ask the user if they want to create the file. If the user confirms, we will create the file using `open` with the 'w' flag and add it to `matched_files` so that it gets added in the for loop.

Here are the changes to the `aider/commands.py` file:

```python
aider/commands.py
<<<<<<< ORIGINAL
from rich.text import Text
from prompt_toolkit.completion import Completion
from aider import prompts
=======
from rich.text import Text
from rich.prompt import Confirm
from prompt_toolkit.completion import Completion
from aider import prompts
>>>>>>> UPDATED

aider/commands.py
<<<<<<< ORIGINAL
        for word in args.split():
            matched_files = [file for file in files if word in file]
            if not matched_files:
                self.console.print(f"[red]No files matched '{word}'")
=======
        for word in args.split():
            matched_files = [file for file in files if word in file]
            if not matched_files:
                create_file = Confirm.ask(f"No files matched '{word}'. Do you want to create the file?")
                if create_file:
                    with open(os.path.join(self.coder.root, word), 'w') as new_file:
                        pass
                    matched_files = [word]
                else:
                    self.console.print(f"[red]No files matched '{word}'")
>>>>>>> UPDATED
```

These changes import `Confirm` from `rich.prompt` and use it to ask the user if they want to create a new file when no matching files are found. If the user confirms, the new file is created and added to `matched_files`.
2023-05-10 19:36:51 -07:00
Paul Gauthier
cda834f7fd updated readme 2023-05-10 19:32:23 -07:00
Paul Gauthier
ad4e1659aa better /ls output 2023-05-10 19:31:57 -07:00
Paul Gauthier
fb04016ec9 Use cwd if no files provided 2023-05-10 19:29:31 -07:00
Paul Gauthier
6e1282202d aider: Changed nargs attribute of "files" argument to make it optional.
# Context:
USER: make the file args optionall. the user can run the command without specifying files.
ASSISTANT: To make the file arguments optional, we need to change the nargs attribute of the "files" argument in the ArgumentParser.

```python
aider/main.py
<<<<<<< ORIGINAL
    parser.add_argument(
        "files",
        metavar="FILE",
        nargs="+",
        help="a list of source code files",
    )
=======
    parser.add_argument(
        "files",
        metavar="FILE",
        nargs="*",
        help="a list of source code files (optional)",
    )
>>>>>>> UPDATED
```
2023-05-10 19:28:58 -07:00
Paul Gauthier
775fbe95f9 allow directories to be provided on the command line; use them to find the git repo 2023-05-10 19:27:45 -07:00
Paul Gauthier
35a4a14a6a Avoid sending 2 copies of the added files 2023-05-10 19:13:33 -07:00
Paul Gauthier
b139dbf475 refactor 2023-05-10 18:41:36 -07:00
Paul Gauthier
fcaf4e15c8 reply with new files content on /add 2023-05-10 18:33:04 -07:00
Paul Gauthier
7a0e020c66 undo print & reply 2023-05-10 18:27:05 -07:00
Paul Gauthier
79d38b5d68 handle the simple replace case quickly 2023-05-10 18:21:41 -07:00
Paul Gauthier
395cf4c14f wip: Added a new prompt message for undo command and updated the message format. 2023-05-10 18:14:47 -07:00
Paul Gauthier
bce64f1986 allow commands to reply to gpt; /undo tells it with discarded the changes 2023-05-10 18:08:33 -07:00
Paul Gauthier
fcacc3c139 noop 2023-05-10 18:05:30 -07:00
Paul Gauthier
ee73e8eb41 noop 2023-05-10 18:02:50 -07:00
Paul Gauthier
b74779d1b7 bugfixes 2023-05-10 18:01:09 -07:00
Paul Gauthier
f8939c55a5 aider: Updated the Usage section in README.md to show the new environment variable default for the --model command-line argument.
# Context:
USER: update readme
ASSISTANT: Please provide more information about what you would like to update in the README.md file.
USER: so usage shows the new env default for --model
ASSISTANT: I will update the Usage section in the README.md file to show the new environment variable default for the `--model` command-line argument.

```python
README.md
<<<<<<< ORIGINAL
- `--model MODEL`: Specify the model to use for the main chat (default: gpt-4). No environment variable override.
=======
- `--model MODEL`: Specify the model to use for the main chat (default: gpt-4). Override with the environment variable `AIDER_MODEL`.
>>>>>>> UPDATED
```

Now, the Usage section in the README.md file shows the environment variable default for the `--model` command-line argument.
2023-05-10 17:58:34 -07:00
Paul Gauthier
1fedba8505 aider: Added environment variable override for --model command-line argument.
# Context:
USER: add an env override for --model
ASSISTANT: I will add an environment variable override for the `--model` command-line argument in the `aider/main.py` file.

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

Now, the `--model` command-line argument can be overridden using the `AIDER_MODEL` environment variable.
2023-05-10 17:57:51 -07:00
Paul Gauthier
8ce2f381b8 Added --commit-dirty option to commit dirty files without confirmation on launch. 2023-05-10 17:56:57 -07:00
Paul Gauthier
5e438941ce aider: Updated the Usage section in README.md to explain all the command-line arguments and their environment variable overrides.
# Context:
USER: update the Usage section to explain all the command line args and their env overrides
ASSISTANT: I will update the Usage section in the README.md file to explain all the command-line arguments and their environment variable overrides.

```python
README.md
<<<<<<< ORIGINAL
Run the Aider tool by executing the following command:

```
aider <file1> <file2> ...
```

Replace `<file1>`, `<file2>`, etc., with the paths to the source code files you want to work on.

You can also use additional command-line options to customize the behavior of the tool. The following options are available:

- `--history-file HISTORY_FILE`: Specify the history file (default: .aider.history, AIDER_HISTORY_FILE).
- `--model MODEL`: Specify the model to use for the main chat (default: gpt-4).
- `-3`: Use gpt-3.5-turbo model for the main chat (basically won't work).
- `--no-pretty`: Disable pretty, colorized output (AIDER_PRETTY).
- `--apply FILE`: Apply the changes from the given file instead of running the chat.
- `--commit-dirty`: On launch, commit dirty files w/o confirmation (default: False, AIDER_COMMIT_DIRTY).
- `--show-diffs`: Show diffs when committing changes (default: False, AIDER_SHOW_DIFFS).
=======
Run the Aider tool by executing the following command:

```
aider <file1> <file2> ...
```

Replace `<file1>`, `<file2>`, etc., with the paths to the source code files you want to work on.

You can also use additional command-line options to customize the behavior of the tool. The following options are available, along with their corresponding environment variable overrides:

- `--history-file HISTORY_FILE`: Specify the history file (default: .aider.history). Override with the environment variable `AIDER_HISTORY_FILE`.
- `--model MODEL`: Specify the model to use for the main chat (default: gpt-4). No environment variable override.
- `-3`: Use gpt-3.5-turbo model for the main chat (basically won't work). No environment variable override.
- `--no-pretty`: Disable pretty, colorized output. Override with the environment variable `AIDER_PRETTY` (default: 1 for enabled, 0 for disabled).
- `--apply FILE`: Apply the changes from the given file instead of running the chat. No environment variable override.
- `--commit-dirty`: On launch, commit dirty files without confirmation (default: False). Override with the environment variable `AIDER_COMMIT_DIRTY` (default: 0 for False, 1 for True).
- `--show-diffs`: Show diffs when committing changes (default: False). Override with the environment variable `AIDER_SHOW_DIFFS` (default: 0 for False, 1 for True).
>>>>>>> UPDATED
```

This update provides a clearer explanation of the command-line arguments and their environment variable overrides.
2023-05-10 17:56:37 -07:00
Paul Gauthier
4c139ee0a2 wip: Changed the help message for the history file and removed the commit-dirty option, added a debug option to apply changes from a file. 2023-05-10 17:54:49 -07:00
Paul Gauthier
1b7b0fddfe aider: Updated Usage section in README.md to explain all the command line arguments and their environment variable overrides.
# Context:
USER: update the Usage section to explain all the command line args and their env overrides
ASSISTANT: I will update the Usage section in the README.md file to explain all the command line arguments and their environment variable overrides.

```python
README.md
<<<<<<< ORIGINAL
Run the Aider tool by executing the following command:

```
aider <file1> <file2> ...
```

Replace `<file1>`, `<file2>`, etc., with the paths to the source code files you want to work on.

You can also use additional command-line options to customize the behavior of the tool. For more information, run `aider --help`. Many defaults can be set with `.env` or environment variables, see the help output.
=======
Run the Aider tool by executing the following command:

```
aider <file1> <file2> ...
```

Replace `<file1>`, `<file2>`, etc., with the paths to the source code files you want to work on.

You can also use additional command-line options to customize the behavior of the tool. The following options are available:

- `--history-file HISTORY_FILE`: Specify the history file (default: .aider.history, AIDER_HISTORY_FILE).
- `--model MODEL`: Specify the model to use for the main chat (default: gpt-4).
- `-3`: Use gpt-3.5-turbo model for the main chat (basically won't work).
- `--no-pretty`: Disable pretty, colorized output (AIDER_PRETTY).
- `--apply FILE`: Apply the changes from the given file instead of running the chat.
- `--commit-dirty`: On launch, commit dirty files w/o confirmation (default: False, AIDER_COMMIT_DIRTY).
- `--show-diffs`: Show diffs when committing changes (default: False, AIDER_SHOW_DIFFS).

For more information, run `aider --help`. Many defaults can be set with `.env` or environment variables, see the help output.
>>>>>>> UPDATED
```
2023-05-10 17:52:12 -07:00
Paul Gauthier
42ccd9c550 improved completions for /add and /drop 2023-05-10 17:48:15 -07:00
Paul Gauthier
923e42c176 fixed off by 1 error in replace_most_similar_chunk() 2023-05-10 16:22:08 -07:00
Paul Gauthier
9ad44d5d7a Refactor filename handling for clarity 2023-05-10 16:14:32 -07:00
Paul Gauthier
d50e9755ed aider: Added completions_drop method that returns the list of active files that are also in self.coder.fnames.
# Context:
USER: create completions_drop which returns the list of get_active_files which are also in self.coder.fnames
ASSISTANT: ```python
aider/commands.py
<<<<<<< ORIGINAL
    def cmd_drop(self, args):
        "Remove matching files from the chat"

        for word in args.split():
            matched_files = [
                file
                for file in self.coder.fnames
                if word in os.path.relpath(file, self.coder.root)
            ]
            if not matched_files:
                self.console.print(f"[red]No files matched '{word}'")
            for matched_file in matched_files:
                relative_fname = os.path.relpath(matched_file, self.coder.root)
                self.coder.fnames.remove(matched_file)
                self.console.print(f"[red]Removed {relative_fname} from the chat")
=======
    def completions_drop(self):
        active_files = self.coder.get_active_files()
        return [
            os.path.relpath(file, self.coder.root)
            for file in self.coder.fnames
            if file in active_files
        ]

    def cmd_drop(self, args):
        "Remove matching files from the chat"

        for word in args.split():
            matched_files = [
                file
                for file in self.coder.fnames
                if word in os.path.relpath(file, self.coder.root)
            ]
            if not matched_files:
                self.console.print(f"[red]No files matched '{word}'")
            for matched_file in matched_files:
                relative_fname = os.path.relpath(matched_file, self.coder.root)
                self.coder.fnames.remove(matched_file)
                self.console.print(f"[red]Removed {relative_fname} from the chat")
>>>>>>> UPDATED
```

I added the `completions_drop` method that returns the list of active files that are also in `self.coder.fnames`.
2023-05-10 16:02:29 -07:00
Paul Gauthier
bc43d9ac31 allow /commands to provide their own completions 2023-05-10 16:00:04 -07:00
Paul Gauthier
623d36d831 aider: Implemented get_command_completions method to call the corresponding cmd_{cmd_name}_completions method if it exists and return its result, otherwise return None.
# Context:
USER: implement get_command_completions. it should look for f"cmd_{cmd_name}_completions" and call that function and return the results. if the functionn isn't found return None.
ASSISTANT: To implement the `get_command_completions` method, we will call the corresponding `cmd_{cmd_name}_completions` method if it exists and return its result. If the method is not found, we will return None.

Here's the updated code for `aider/commands.py`:

```python
aider/commands.py
<<<<<<< ORIGINAL
    def get_command_completions(self, cmd_name):
        pass
=======
    def get_command_completions(self, cmd_name):
        cmd_completions_method_name = f"cmd_{cmd_name}_completions"
        cmd_completions_method = getattr(self, cmd_completions_method_name, None)
        if cmd_completions_method:
            return cmd_completions_method()
        else:
            return None
>>>>>>> UPDATED
```
2023-05-10 15:53:58 -07:00
Paul Gauthier
b66ac52388 changed /ls output format 2023-05-10 15:48:31 -07:00
Paul Gauthier
9f55e07849 wip: Changed ls command output to show files in chat with red color. 2023-05-10 15:44:51 -07:00