Commit graph

359 commits

Author SHA1 Message Date
Paul Gauthier
781016b93c Added census chat 2023-05-23 11:41:09 -07:00
Paul Gauthier
c239b7f49c Added ctags --extras=-F to avoid mapping file-private symbols 2023-05-23 07:05:33 -07:00
Paul Gauthier
8a528b655d use tab in ctag maps 2023-05-23 06:54:14 -07:00
Paul Gauthier
560e427684 aider: Updated default values of pretty and yes to True and False respectively in the InputOutput class constructor.
# Context:
USER: give inputoutput defaults of pretty=true and yes=false
ASSISTANT: To update the default values of `pretty` and `yes` in the `InputOutput` class, I will modify the `__init__` method in the `io.py` file.

```python
aider/io.py
<<<<<<< ORIGINAL
    def __init__(self, pretty, yes, input_history_file=None, chat_history_file=None, input=None, output=None):
=======
    def __init__(self, pretty=True, yes=False, input_history_file=None, chat_history_file=None, input=None, output=None):
>>>>>>> UPDATED
```
2023-05-23 06:05:48 -07:00
Paul Gauthier
e09b1cf2d7 Changed /commit command to commit outstanding changes to the repo instead of chat session files. 2023-05-22 09:54:37 -07:00
Paul Gauthier
4f2e1d14ef sort the file list in the prompt 2023-05-20 07:28:23 -07:00
Paul Gauthier
ffe3da4df1 do not sent file lists longer than 100 files 2023-05-19 16:17:40 -07:00
paul-gauthier
7d08c346bb
Merge pull request #4 from mobyvb/prompt-compression
aider/prompts.py: reduce token size of prompts
2023-05-19 16:10:26 -07:00
Paul Gauthier
c441906a22 aider: Made -v a short option for --verbose.
# Context:
USER: make -v short for --verbose
ASSISTANT: To make `-v` a short option for `--verbose`, you can modify the `aider/main.py` file. Here's the change:

```python
aider/main.py
<<<<<<< ORIGINAL
    parser.add_argument(
        "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
=======
    parser.add_argument(
        "-v", "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
>>>>>>> UPDATED
```
2023-05-19 10:57:59 -07:00
Paul Gauthier
7e6ea0660d Refactor show_messages function to accept an optional title parameter and remove unused code. 2023-05-19 10:57:24 -07:00
Paul Gauthier
10e38e1fe9 aider: Added --verbose option to enable verbose output.
# Context:
USER: Add --verbose with no env default. pass into Coder and set self.verbose
ASSISTANT: To add the `--verbose` option, we need to modify the `aider/main.py` file. Here's the step-by-step process:

1. Add the `--verbose` argument to the `argparse.ArgumentParser` in the `main` function.
2. Pass the `args.verbose` value to the `Coder` class when initializing it.
3. Update the `Coder` class in the `aider/coder.py` file to accept the `verbose` parameter and set `self.verbose`.

Here are the changes to the code:

```python
aider/main.py
<<<<<<< ORIGINAL
    parser.add_argument(
        "--yes",
        action="store_true",
        help="Always say yes to every confirmation",
        default=False,
    )
=======
    parser.add_argument(
        "--yes",
        action="store_true",
        help="Always say yes to every confirmation",
        default=False,
    )
    parser.add_argument(
        "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
>>>>>>> UPDATED
```

```python
aider/main.py
<<<<<<< ORIGINAL
    coder = Coder(
        io,
        main_model=args.model,
        fnames=args.files,
        pretty=args.pretty,
        show_diffs=args.show_diffs,
        auto_commits=args.auto_commits,
        dry_run=args.dry_run,
        use_ctags=args.ctags,
    )
=======
    coder = Coder(
        io,
        main_model=args.model,
        fnames=args.files,
        pretty=args.pretty,
        show_diffs=args.show_diffs,
        auto_commits=args.auto_commits,
        dry_run=args.dry_run,
        use_ctags=args.ctags,
        verbose=args.verbose,
    )
>>>>>>> UPDATED
```

```python
aider/coder.py
<<<<<<< ORIGINAL
    def __init__(
        self,
        io,
        main_model="gpt-4",
        fnames=None,
        pretty=True,
        show_diffs=False,
        auto_commits=True,
        dry_run=False,
        use_ctags=False,
    ):
=======
    def __init__(
        self,
        io,
        main_model="gpt-4",
        fnames=None,
        pretty=True,
        show_diffs=False,
        auto_commits=True,
        dry_run=False,
        use_ctags=False,
        verbose=False,
    ):
        self.verbose = verbose
>>>>>>> UPDATED
```
2023-05-19 10:55:48 -07:00
Paul Gauthier
b82bb65b86 help msg for --ctags 2023-05-19 10:49:11 -07:00
Paul Gauthier
32e40a3e1c aider: Prevent gpt-3.5-turbo from generating commit messages for diffs larger than 4k tokens and catch InvalidRequestError.
# Context:
USER: `Coder.get_commit_message()` uses gpt-3.5-turbo to summarize the diffs into a sensible commit message. If the diff is large, it exceeds the 4K context window.

A simple fix would be:

1. Check if the diff is close to or larger than 4 kbytes (4k tokens * 4 bytes/token) and don't even bother sending the messages to gpt. Just return.
2. Catch the `openai.error.InvalidRequestError` and just return.

Maybe print a nice tool_error() message for each of these.

ASSISTANT: To implement the suggested changes, we will modify the `get_commit_message()` method in the `aider/coder.py` file. Here are the step-by-step changes:

1. Check if the length of `diffs` is close to or larger than 4 kbytes (4k tokens * 4 bytes/token). If it is, print an error message and return.
2. Catch the `openai.error.InvalidRequestError` exception when calling `self.send()` and print an error message, then return.

Here are the code changes:

```python
aider/coder.py
<<<<<<< ORIGINAL
    def get_commit_message(self, diffs, context):
        diffs = "# Diffs:\n" + diffs

        messages = [
            dict(role="system", content=prompts.commit_system),
            dict(role="user", content=context + diffs),
        ]

        commit_message, interrupted = self.send(
            messages,
            model="gpt-3.5-turbo",
            silent=True,
        )
=======
    def get_commit_message(self, diffs, context):
        if len(diffs) >= 4 * 1024 * 4:
            self.io.tool_error("Diff is too large for gpt-3.5-turbo to generate a commit message.")
            return

        diffs = "# Diffs:\n" + diffs

        messages = [
            dict(role="system", content=prompts.commit_system),
            dict(role="user", content=context + diffs),
        ]

        try:
            commit_message, interrupted = self.send(
                messages,
                model="gpt-3.5-turbo",
                silent=True,
            )
        except openai.error.InvalidRequestError:
            self.io.tool_error("Failed to generate commit message using gpt-3.5-turbo due to an invalid request.")
            return
>>>>>>> UPDATED
```
2023-05-19 10:41:43 -07:00
Paul Gauthier
af85c81c13 fixed missing case of just the filename 2023-05-19 10:32:55 -07:00
Paul Gauthier
046e6ed9d4 aider: Added in-memory cache to get_tags function using a tuple (filename, root_dname) as the cache key.
# Context:
USER: add an in memory cache to get_tags that only updates if the st_mtime of the filename changes
ASSISTANT: To implement an in-memory cache for the `get_tags` function, we will need to modify the `aider/ctags.py` file. We will use a dictionary to store the cache and check the file's modification time to decide whether to update the cache or not.

Here are the steps to implement the cache:

1. Create a global variable `TAGS_CACHE` to store the cache.
2. In the `get_tags` function, check if the filename is in the cache and if the modification time has not changed.
3. If the conditions in step 2 are met, return the cached value.
4. If the conditions in step 2 are not met, update the cache with the new tags and return them.

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

```python
aider/ctags.py
<<<<<<< ORIGINAL
import os
import json
import sys
import subprocess

# from aider.dump import dump
=======
import os
import json
import sys
import subprocess

# Global cache for tags
TAGS_CACHE = {}

# from aider.dump import dump
>>>>>>> UPDATED
```

```python
aider/ctags.py
<<<<<<< ORIGINAL
def get_tags(filename, root_dname):
    cmd = ["ctags", "--fields=+S", "--output-format=json", filename]
    output = subprocess.check_output(cmd).decode("utf-8")
    output = output.splitlines()
=======
def get_tags(filename, root_dname):
    # Check if the file is in the cache and if the modification time has not changed
    file_mtime = os.path.getmtime(filename)
    if filename in TAGS_CACHE and TAGS_CACHE[filename]["mtime"] == file_mtime:
        return TAGS_CACHE[filename]["tags"]

    cmd = ["ctags", "--fields=+S", "--output-format=json", filename]
    output = subprocess.check_output(cmd).decode("utf-8")
    output = output.splitlines()
>>>>>>> UPDATED
```

```python
aider/ctags.py
<<<<<<< ORIGINAL
    for line in output:
        tag = json.loads(line)
        path = tag.get("path")
        scope = tag.get("scope")
        kind = tag.get("kind")
        name = tag.get("name")
        signature = tag.get("signature")

        last = name
        if signature:
            last += " " + signature

        res = split_path(path, root_dname)
        if scope:
            res.append(scope)
        res += [kind, last]

        yield res
=======
    tags = []
    for line in output:
        tag = json.loads(line)
        path = tag.get("path")
        scope = tag.get("scope")
        kind = tag.get("kind")
        name = tag.get("name")
        signature = tag.get("signature")

        last = name
        if signature:
            last += " " + signature

        res = split_path(path, root_dname)
        if scope:
            res.append(scope)
        res += [kind, last]
        tags.append(res)

    #
^C KeyboardInterrupt
USER: sorry, please do that again. but set key=(filename, root_dname) and use that as the cache key
ASSISTANT: No problem. I will modify the cache implementation to use a tuple (filename, root_dname) as the cache key. Here are the updated changes to the `aider/ctags.py` file:

```python
aider/ctags.py
<<<<<<< ORIGINAL
import os
import json
import sys
import subprocess

# from aider.dump import dump
=======
import os
import json
import sys
import subprocess

# Global cache for tags
TAGS_CACHE = {}

# from aider.dump import dump
>>>>>>> UPDATED
```

```python
aider/ctags.py
<<<<<<< ORIGINAL
def get_tags(filename, root_dname):
    cmd = ["ctags", "--fields=+S", "--output-format=json", filename]
    output = subprocess.check_output(cmd).decode("utf-8")
    output = output.splitlines()
=======
def get_tags(filename, root_dname):
    # Check if the file is in the cache and if the modification time has not changed
    file_mtime = os.path.getmtime(filename)
    cache_key = (filename, root_dname)
    if cache_key in TAGS_CACHE and TAGS_CACHE[cache_key]["mtime"] == file_mtime:
        return TAGS_CACHE[cache_key]["tags"]

    cmd = ["ctags", "--fields=+S", "--output-format=json", filename]
    output = subprocess.check_output(cmd).decode("utf-8")
    output = output.splitlines()
>>>>>>> UPDATED
```

```python
aider/ctags.py
<<<<<<< ORIGINAL
    for line in output:
        tag = json.loads(line)
        path = tag.get("path")
        scope = tag.get("scope")
        kind = tag.get("kind")
        name = tag.get("name")
        signature = tag.get("signature")

        last = name
        if signature:
            last += " " + signature

        res = split_path(path, root_dname)
        if scope:
            res.append(scope)
        res += [kind, last]

        yield res
=======
    tags = []
    for line in output:
        tag = json.loads(line)
        path = tag.get("path")
        scope = tag.get("scope")
        kind = tag.get("kind")
        name = tag.get("name")
        signature = tag.get("signature")

        last = name
        if signature:
            last += " " + signature

        res = split_path(path, root_dname)
        if scope:
            res.append(scope)
        res += [kind, last]
        tags.append(res)

    # Update the cache
    TAGS_CACHE[cache_key] = {"mtime": file_mtime, "tags": tags}

    return tags
>>>>>>> UPDATED
```
2023-05-19 10:32:02 -07:00
Paul Gauthier
9a243d7adc sssh 2023-05-19 10:19:23 -07:00
Paul Gauthier
1391e9de9b aider: Updated cmd_run method in aider/commands.py to use the io version of Confirm.ask().
# Context:
USER: in commands, switch the Confirm.ask() calls to use the io versions
ASSISTANT: I will update the `cmd_add` method in the `aider/commands.py` file to use the `io` versions of `Confirm.ask()`.

^C KeyboardInterrupt
USER: switch the Confirm.ask() calls to use the io versions
ASSISTANT: I will update the `cmd_add` method in the `aider/commands.py` file to use the `io` versions of `Confirm.ask()`.

```python
aider/commands.py
<<<<<<< ORIGINAL
                if self.coder.repo is not None:
                    create_file = self.io.confirm_ask(
                        (
                            f"No files matched
^C KeyboardInterrupt
USER: no, they already do. cmd_run
ASSISTANT: I apologize for the confusion. I will update the `cmd_run` method in the `aider/commands.py` file to use the `io` version of `Confirm.ask()`.

```python
aider/commands.py
<<<<<<< ORIGINAL
        ok = Confirm.ask("Add the output to the chat?", default="y")
=======
        ok = self.io.confirm_ask("Add the output to the chat?", default="y")
>>>>>>> UPDATED
```
2023-05-19 10:18:49 -07:00
Paul Gauthier
f6aaa19299 implement --ctags 2023-05-19 10:07:52 -07:00
Paul Gauthier
68c58ea394 aider: Added --ctags argument and environment variable to pass to Coder class.
# Context:
USER: add a --ctags arg and env var. pass it to Coder to set self.use_ctags
ASSISTANT: To add a `--ctags` argument and environment variable, and pass it to the `Coder` class, follow these steps:

1. Modify `aider/main.py` to add the `--ctags` argument and read the environment variable.
2. Modify the `Coder` class in `aider/coder.py` to accept the `use_ctags` parameter and set it as an instance variable.

Here are the necessary code changes:

```python
aider/main.py
<<<<<<< ORIGINAL
    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))),
    )
=======
    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))),
    )
    parser.add_argument(
        "--ctags",
        action="store_true",
        help=f"Use ctags for file listing (default: False, ${env_prefix}CTAGS)",
        default=bool(int(os.environ.get(f"{env_prefix}CTAGS", 0))),
    )
>>>>>>> UPDATED
```

```python
aider/main.py
<<<<<<< ORIGINAL
    coder = Coder(
        io,
        main_model=args.model,
        fnames=args.files,
        pretty=args.pretty,
        show_diffs=args.show_diffs,
        auto_commits=args.auto_commits,
        dry_run=args.dry_run,
    )
=======
    coder = Coder(
        io,
        main_model=args.model,
        fnames=args.files,
        pretty=args.pretty,
        show_diffs=args.show_diffs,
        auto_commits=args.auto_commits,
        dry_run=args.dry_run,
        use_ctags=args.ctags,
    )
>>>>>>> UPDATED
```

```python
aider/coder.py
<<<<<<< ORIGINAL
    def __init__(
        self,
        io,
        main_model="gpt-4",
        fnames=None,
        pretty=True,
        show_diffs=False,
        auto_commits=True,
        dry_run=False,
    ):
=======
    def __init__(
        self,
        io,
        main_model="gpt-4",
        fnames=None,
        pretty=True,
        show_diffs=False,
        auto_commits=True,
        dry_run=False,
        use_ctags=False,
    ):
        self.use_ctags = use_ctags
>>>>>>> UPDATED
```

These changes add the `--ctags` argument, read the environment variable, and pass the `use_ctags` parameter to the `Coder` class.
2023-05-19 10:02:21 -07:00
Paul Gauthier
8f7d7685d6 improved prompting around ctags 2023-05-19 09:54:27 -07:00
Paul Gauthier
680fc45fb3 improved prompting, fix ctags bug 2023-05-19 09:47:06 -07:00
Paul Gauthier
4593e7812c aider: Replaced Confirm.ask() calls with self.io.confirm_ask() in commands.py.
# Context:
USER: in commands, switch the ask() calls to use the io versions
ASSISTANT: I need to see the content of the `commands.py` file to make the necessary changes. Please provide the content of the file.
USER: Please note that I shared content of these additional files: aider/commands.py
ASSISTANT: I apologize for the oversight. I will now make the necessary changes to the `commands.py` file.

```python
aider/commands.py
<<<<<<< ORIGINAL
                    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?"
                    )
=======
                    create_file = self.io.confirm_ask(
                        (
                            f"No files matched '{word}'. Do you want to create the file and add it"
                            " to git?"
                        ),
                    )
                else:
                    create_file = self.io.confirm_ask(
                        f"No files matched '{word}'. Do you want to create the file?"
                    )
>>>>>>> UPDATED
```

I have replaced the `Confirm.ask()` calls with `self.io.confirm_ask()` as requested.
2023-05-19 09:20:54 -07:00
Paul Gauthier
9536a8d1b9 bugfix 2023-05-19 09:14:55 -07:00
Paul Gauthier
37812084c1 forget about cmd_add test 2023-05-19 09:04:35 -07:00
Paul Gauthier
6dececea84 tweaked layout 2023-05-19 09:04:01 -07:00
Paul Gauthier
73fadbf2f8 wip: Added import statement for get_tags_map function from aider.ctags module. 2023-05-19 08:58:20 -07:00
Paul Gauthier
d4845dfb43 wip: Changed the prompt messages and added a function to show messages. 2023-05-19 08:57:56 -07:00
Paul Gauthier
e4d38f89bb return string 2023-05-19 08:51:49 -07:00
Paul Gauthier
f8d8a3528b include files with no tags 2023-05-19 08:47:17 -07:00
Paul Gauthier
dfd2c495ea move import 2023-05-19 08:42:28 -07:00
Paul Gauthier
f5c6667de3 aider: Modified get_tags to run ctags command and capture JSON output.
# Context:
USER: in get_tags, run `ctags --fields=+S --output-format=json $f` on the filename and collect the json output instead of reading json from filename. use that json data for the rest of the func
ASSISTANT: To modify the `get_tags` function in `aider/ctags.py` to run `ctags --fields=+S --output-format=json $f` on the filename and collect the JSON output, we will need to use the `subprocess` module to run the command and capture the output. Here are the changes:

```python
aider/ctags.py
<<<<<<< ORIGINAL
def get_tags(filename):
    with open(filename, "r") as tags_file:
        for line in tags_file:
            tag = json.loads(line)
=======
import subprocess

def get_tags(filename):
    cmd = ["ctags", "--fields=+S", "--output-format=json", filename]
    output = subprocess.check_output(cmd).decode("utf-8")
    for line in output.splitlines():
        tag = json.loads(line)
>>>>>>> UPDATED
```

This change imports the `subprocess` module, replaces the `with open(filename, "r")` block with a `subprocess.check_output` call to run the `ctags` command, and iterates over the output lines instead of the file lines.
2023-05-19 08:42:09 -07:00
Paul Gauthier
efe05b6d8a path 2023-05-19 08:39:04 -07:00
Paul Gauthier
06a33bc1b1 aider: Added path_components variable to store the split path.
# Context:
USER: after relpath, split path into a list of its components
ASSISTANT: ```python
aider/ctags.py
<<<<<<< ORIGINAL
            path = os.path.relpath(path, os.getcwd())
=======
            path = os.path.relpath(path, os.getcwd())
            path_components = path.split(os.sep)
>>>>>>> UPDATED
```
2023-05-19 08:31:26 -07:00
Paul Gauthier
cceb7c3bef Refactor ctags.py to print tags with indentation. 2023-05-19 08:31:00 -07:00
Paul Gauthier
7d45b918fc cleanup 2023-05-19 07:14:45 -07:00
Paul Gauthier
95221d58c9 closer 2023-05-19 07:00:12 -07:00
Paul Gauthier
36bbf879b5 tabbed for brevity 2023-05-19 06:38:19 -07:00
Paul Gauthier
cf63fd31d5 no n/a 2023-05-19 06:24:49 -07:00
Paul Gauthier
4bb0dc72cd aider: Modified ctags.py to accept command line arguments and call print_tags_info on each file provided.
# Context:
USER: take filenames from the cmd line, call print_tags_info on each
ASSISTANT: To achieve this, we will modify the `aider/ctags.py` file to accept command line arguments and call `print_tags_info` on each file provided.

1. Import the `sys` module to access command line arguments.
2. Modify the `print_tags_info` function to accept a filename parameter.
3. Update the `with open` statement to use the provided filename.
4. Update the `if __name__ == "__main__":` block to iterate over command line arguments and call `print_tags_info` for each file.

Here are the changes:

```python
aider/ctags.py
<<<<<<< ORIGINAL
import json

def print_tags_info():
    with open("tags.jsonl", "r") as tags_file:
=======
import json
import sys

def print_tags_info(filename):
    with open(filename, "r") as tags_file:
>>>>>>> UPDATED
```

```python
aider/ctags.py
<<<<<<< ORIGINAL
if __name__ == "__main__":
    print_tags_info()
=======
if __name__ == "__main__":
    for filename in sys.argv[1:]:
        print_tags_info(filename)
>>>>>>> UPDATED
```
2023-05-18 18:30:40 -07:00
Paul Gauthier
6e68120acb wip: Changed print statement to remove f-string. 2023-05-18 18:29:37 -07:00
Paul Gauthier
1b3a4084be aider: Added function to load and iterate through tags file and print desired fields.
# Context:
USER: load the tags file and iterate through the records, print scope,kind,name,signature
ASSISTANT: To load the tags file and iterate through the records, you can use the following code:

1. Import the `json` module.
2. Open the `tags.jsonl` file.
3. Iterate through the lines in the file, loading each JSON object.
4. Print the desired fields: scope, kind, name, and signature.

Here's the code:

```python
import json

with open("tags.jsonl", "
^C KeyboardInterrupt
USER: put it in ctags.py
ASSISTANT: Here's the updated `aider/ctags.py` file with the code to load the tags file and iterate through the records, printing scope, kind, name, and signature:

```python
aider/ctags.py
<<<<<<< ORIGINAL
=======
import json

def print_tags_info():
    with open("tags.jsonl", "r") as tags_file:
        for line in tags_file:
            tag = json.loads(line)
            scope = tag.get("scope", "N/A")
            kind = tag.get("kind", "N/A")
            name = tag.get("name", "N/A")
            signature = tag.get("signature", "N/A")
            print(f"Scope: {scope}, Kind: {kind}, Name: {name}, Signature: {signature}")

if __name__ == "__main__":
    print_tags_info()
>>>>>>> UPDATED
```

This code defines a function `print_tags_info()` that reads the `tags.jsonl` file, iterates through the records, and prints the desired fields. The `if __name__ == "__main__":` block allows the script to be run directly.
2023-05-18 18:28:21 -07:00
Paul Gauthier
5e010422e2 Added new files to the git repo: tags.jsonl, aider/ctags.py 2023-05-18 18:26:24 -07:00
Paul Gauthier
ba9307374e cleanup Coder params 2023-05-18 18:21:44 -07:00
Paul Gauthier
78af36ffda cleanup 2023-05-18 18:17:02 -07:00
Paul Gauthier
7fc02ccd66 wip 2023-05-18 18:15:41 -07:00
Paul Gauthier
7e6c6b3b92 initialize cur_ and done_messages 2023-05-18 18:09:37 -07:00
Paul Gauthier
01778be259 fixed indent 2023-05-18 17:33:11 -07:00
Paul Gauthier
1814638c1a aider: Fixed indentation error in aider/io.py.
# Context:
USER: I ran this command:

 pytest tests/test_commands.py

Which produced this output:

============================= test session starts ==============================
platform darwin -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/gauthier/Projects/aider
collected 0 items / 1 error

==================================== ERRORS ====================================
___________________ ERROR collecting tests/test_commands.py ____________________
.venv/lib/python3.11/site-packages/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
.venv/lib/python3.11/site-packages/_pytest/pathlib.py:564: in import_path
    importlib.import_module(module_name)
/usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1206: in _gcd_import
    ???
<frozen importlib._bootstrap>:1178: in _find_and_load
    ???
<frozen importlib._bootstrap>:1149: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
.venv/lib/python3.11/site-packages/_pytest/assertion/rewrite.py:172: in exec_module
    exec(co, module.__dict__)
tests/test_commands.py:6: in <module>
    from aider.io import InputOutput as IO
E     File "/Users/gauthier/Projects/aider/aider/io.py", line 117
E       line = session.prompt()
E   IndentationError: unexpected indent
=========================== short test summary info ============================
ERROR tests/test_commands.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.32s ===============================

ASSISTANT: It seems there is an indentation error in the `aider/io.py` file. Please provide the content of the `aider/io.py` file so I can identify the issue and suggest a fix.
USER: Please note that I shared content of these additional files: aider/io.py
ASSISTANT: Apologies for the oversight. I see the indentation error in the `aider/io.py` file. Here's the fix:

```python
aider/io.py
<<<<<<< ORIGINAL
        session_kwargs = {
            "message": show,
            "completer": completer_instance,
            "style": style,
            "reserve_space_for_menu": 4,
            "complete_style": CompleteStyle.MULTI_COLUMN,
            "input": self.input,
            "output": self.output,
        }
        if self.input_history_file is not None:
            session_kwargs["history"] = FileHistory(self.input_history_file)
        session = PromptSession(**session_kwargs)
            line = session.prompt()
=======
        session_kwargs = {
            "message": show,
            "completer": completer_instance,
            "style": style,
            "reserve_space_for_menu": 4,
            "complete_style": CompleteStyle.MULTI_COLUMN,
            "input": self.input,
            "output": self.output,
        }
        if self.input_history_file is not None:
            session_kwargs["history"] = FileHistory(self.input_history_file)
        session = PromptSession(**session_kwargs)
        line = session.prompt()
>>>>>>> UPDATED
```

This should fix the indentation error. Please apply the change and run the tests again.
2023-05-18 17:32:33 -07:00
Paul Gauthier
aa8ead2f2e aider: Made the two history files optional.
# Context:
USER: make the two history files optional
ASSISTANT: To make the two history files optional, we will modify the `__init__` method of the `InputOutput` class in the `aider/io.py` file. We will set the default values of `input_history_file` and `chat_history_file` to `None`. Then, we will add conditions to check if these variables are not `None` before using them.

```python
aider/io.py
<<<<<<< ORIGINAL
    def __init__(self, pretty, yes, input_history_file, chat_history_file, input=None, output=None):
=======
    def __init__(self, pretty, yes, input_history_file=None, chat_history_file=None, input=None, output=None):
>>>>>>> UPDATED
```

```python
aider/io.py
<<<<<<< ORIGINAL
        session = PromptSession(
            message=show,
            completer=completer_instance,
            history=FileHistory(self.input_history_file),
            style=style,
            reserve_space_for_menu=4,
            complete_style=CompleteStyle.MULTI_COLUMN,
            input=self.input,
            output=self.output,
        )
=======
        session_kwargs = {
            "message": show,
            "completer": completer_instance,
            "style": style,
            "reserve_space_for_menu": 4,
            "complete_style": CompleteStyle.MULTI_COLUMN,
            "input": self.input,
            "output": self.output,
        }
        if self.input_history_file is not None:
            session_kwargs["history"] = FileHistory(self.input_history_file)
        session = PromptSession(**session_kwargs)
>>>>>>> UPDATED
```

```python
aider/io.py
<<<<<<< ORIGINAL
        self.chat_history_file = Path(chat_history_file)
=======
        if chat_history_file is not None:
            self.chat_history_file = Path(chat_history_file)
        else:
            self.chat_history_file = None
>>>>>>> UPDATED
```

```python
aider/io.py
<<<<<<< ORIGINAL
        with self.chat_history_file.open("a") as f:
            f.write(text)
=======
        if self.chat_history_file is not None:
            with self.chat_history_file.open("a") as f:
                f.write(text)
>>>>>>> UPDATED
```

These changes will make the history files optional.
2023-05-18 17:30:34 -07:00
Moby von Briesen
24b273b935 aider/prompts.py: reduce prompt size
get rid of nonessential information that causes the prompt to be longer
than needed

main system prompt: 924 chars -> 741 chars (183 chars saved)
system reminder prompt: 1304 chars -> 1168 chars (136 chars saved)
2023-05-18 18:33:29 -04:00