Commit graph

10395 commits

Author SHA1 Message Date
Paul Gauthier
f2dcfe3723 updated readme 2023-05-09 11:56:23 -07:00
Paul Gauthier
4aa46c2714 updated readme 2023-05-09 11:52:32 -07:00
Paul Gauthier
bcc8b29cf7 Add "Features" section to README.md file.
# Context:
USER: add a features section
ASSISTANT: To add a features section, I will update the README.md file. Here's the change:

```python
README.md
<<<<<<< ORIGINAL
Aider is a command-line tool that allows you to chat with GPT about your code.
It can make changes, improvements, and bug fixes to your code with the assistance of GPT.
=======
Aider is a command-line tool that allows you to chat with GPT about your code.
It can make changes, improvements, and bug fixes to your code with the assistance of GPT.

## Features

* Chat with GPT about your code
* Make changes, improvements, and bug fixes to your code
* Automatically commit changes to a Git repository
* Colorized output for better readability
* Supports multiple source code files
>>>>>>> UPDATED
```

This change adds a "Features" section to the README.md file, listing some of the main features of the Aider tool.
2023-05-09 11:42:43 -07:00
Paul Gauthier
402d4e4720 readme edits 2023-05-09 11:41:58 -07:00
Paul Gauthier
eb1372236d Update README.md with installation and usage instructions for Aider tool.
# Context:
USER: Use ORIGINAL/UPDATE format to provide a README.md for this tool
ASSISTANT: Here's a basic README.md for the Aider tool using the ORIGINAL/UPDATED format:

```
README.md
<<<<<<< ORIGINAL

=======
# Aider

Aider is a command-line tool that allows you to chat with GPT about your code. It helps you to make changes, improvements, and bug fixes to your code with the assistance of GPT.

## Installation

1. Clone the repository.
2. Install the required packages using `pip install -r requirements.txt`.
3. Set up your OpenAI API key as an environment variable `OPENAI_API_KEY`.

## Usage

Run the Aider tool by executing the following command:

```
python -m aider.main <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:

```
python -m aider.main --help
```
>>>>>>> UPDATED
```

This will create a README.md file with a brief description, installation, and usage instructions for the Aider tool.
2023-05-09 11:40:27 -07:00
Paul Gauthier
c1e4f0d7e7 Initial commit: Added new files to the git repo: README.md 2023-05-09 11:38:44 -07:00
Paul Gauthier
a591c09a1a fixed import 2023-05-09 11:36:46 -07:00
Paul Gauthier
a2eb1aff11 Use relative import for Coder class in main.py
# Context:
USER: $ python3 ./aider/main.py
Traceback (most recent call last):
  File "/Users/gauthier/Projects/aider/./aider/main.py", line 5, in <module>
    from aider.coder import Coder
ModuleNotFoundError: No module named 'aider'

ASSISTANT: It seems like there is an issue with importing the `Coder` class from the `aider` package. To fix this, you can try adding the current directory to the `sys.path`. Here's the change you need to make in the `aider/main.py` file:

```python
aider/main.py
<<<<<<< ORIGINAL
import os
import sys
import argparse
from dotenv import load_dotenv
from aider.coder import Coder
=======
import os
import sys
sys.path.append(os.path.dirname(os.path
^C KeyboardInterrupt
USER: i would rather not do that. is there a different way to do the import so that it works both when the aider package is pip installed and also when its being run from the repo checkout?
ASSISTANT: Yes, you can use a relative import instead of an absolute import. This will work both when the package is installed via pip and when it's being run from the repo checkout. Here's the change you need to make in the `aider/main.py` file:

```python
aider/main.py
<<<<<<< ORIGINAL
from dotenv import load_dotenv
from aider.coder import Coder
=======
from dotenv import load_dotenv
from .coder import Coder
>>>>>>> UPDATED
```

This change replaces the absolute import with a relative import, which should resolve the `ModuleNotFoundError`.
2023-05-09 11:34:07 -07:00
Paul Gauthier
8e79a7cf9b WIP: Refactor import statement for Coder in main.py. 2023-05-09 11:32:52 -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
3ff28a111b initial 2023-05-09 11:00:32 -07:00
Paul Gauthier
2333e62b6a Add setup.py file that reads requirements.txt for dependencies and sets up CLI script.
# Context:
USER: make a setup.py for this project. it includes a cli script in main(). have setup.py read requirements.txt to get the install_requires
ASSISTANT: To create a `setup.py` file for this project, we'll use the `setuptools` package. We'll also read the `requirements.txt` file to get the `install_requires` dependencies. Here's the change:

```python
setup.py
<<<<<<< ORIGINAL

=======
from setuptools import setup, find_packages

with open("requirements.txt") as f:
    requirements = f.read().splitlines()

setup(
    name="aider",
    version="0.1.0",
    packages=find_packages(),
    install_requires=requirements,
    entry_points={
        "console_scripts": [
            "aider = aider.main:main",
        ],
    },
)
>>>>>>> UPDATED
```

This will create a `setup.py` file that reads the `requirements.txt` file for dependencies and sets up the CLI script for the `main()` function in `aider.main`.
2023-05-09 10:57:56 -07:00
Paul Gauthier
e32fb7c033 Initial commit: Added new files to the git repo: setup.py 2023-05-09 10:56:14 -07:00
Paul Gauthier
ff887b5c3e initial 2023-05-09 10:55:05 -07:00
Paul Gauthier
984e2f78ce moved into subdir 2023-05-09 10:52:18 -07:00
Paul Gauthier
a6b9023079 WIP: Change default history file name to ".aider.history 2023-05-09 10:51:43 -07:00
Paul Gauthier
786fb61bad changed name to aider, improved help 2023-05-09 10:24:28 -07:00
Paul Gauthier
1475e0d0fd Replace hardcoded "$CODER_" strings with f-strings that use the env_prefix variable.
# Context:
USER: You missed a bunch of explicit $CODER_xxx
ASSISTANT: I apologize for that. I will replace the remaining hardcoded "$CODER_" strings with f-strings that use the `env_prefix` variable.

```python
main.py
<<<<<<< ORIGINAL
        help="Disable pretty output of GPT responses ($CODER_PRETTY)",
=======
        help=f"Disable pretty output of GPT responses (${{{env_prefix}}}PRETTY)",
>>>>>>> UPDATED

main.py
<<<<<<< ORIGINAL
        help="Commit dirty files without confirmation (default: False, $CODER_COMMIT_DIRTY)",
=======
        help=f"Commit dirty files without confirmation (default: False, ${{{env_prefix}}}COMMIT_DIRTY)",
>>>>>>> UPDATED
```

Please let me know if there are any other instances that need to be updated.
2023-05-09 10:19:18 -07:00
Paul Gauthier
66058fd123 Replace hardcoded strings with f-strings that use env_prefix.
# Context:
USER: change all the hardcoded $CODER_... strings to be f-strings that use env_prefix
ASSISTANT: I will replace the hardcoded "$CODER_" strings with f-strings that use the `env_prefix` variable.

```python
main.py
<<<<<<< ORIGINAL
        default=os.environ.get("CODER_HISTORY_FILE", ".coder.history"),
        help="Specify the history file (default: .coder.history, $CODER_HISTORY_FILE)",
=======
        default=os.environ.get(f"{env_prefix}HISTORY_FILE", ".coder.history"),
        help="Specify the history file (default: .coder.history, ${env_prefix}HISTORY_FILE)",
>>>>>>> UPDATED

main.py
<<<<<<< ORIGINAL
        default=bool(int(os.environ.get(env_prefix + "PRETTY", 1))),
=======
        default=bool(int(os.environ.get(f"{env_prefix}PRETTY", 1))),
>>>>>>> UPDATED

main.py
<<<<<<< ORIGINAL
        default=bool(int(os.environ.get(env_prefix + "COMMIT_DIRTY", 0))),
=======
        default=bool(int(os.environ.get(f"{env_prefix}COMMIT_DIRTY", 0))),
>>>>>>> UPDATED
```
2023-05-09 10:18:11 -07:00
Paul Gauthier
c6197fd121 WIP: Refactor Coder class to use set instead of dict for fnames. 2023-05-09 10:15:33 -07:00
Paul Gauthier
82cf653d73 refactored into getinput 2023-05-09 10:11:54 -07:00
Paul Gauthier
6419e6c390 Move get_input function into utils.py and update the call to get_input in coder.py to use the new utils.get_input function.
# Context:
USER: move get_input into utils. pass in history_file and fnames as params rather than referencing them with self.
ASSISTANT: To move the `get_input` function into `utils.py`, we will remove it from the `Coder` class in `coder.py` and add it to `utils.py`. We will also update the function to accept `history_file` and `fnames` as parameters.

```python
coder.py
<<<<<<< ORIGINAL
    def get_input(self):
        inp = ""
        multiline_input = False

        style = Style.from_dict({'': 'green'})

        while True:
            completer_instance = FileContentCompleter(self.fnames)
            if multiline_input:
                show = ". "
            else:
                show = "> "

            try:
                line = prompt(
                    show,
                    completer=completer_instance,
                    history=FileHistory(self.history_file),
                    style=style,
                )
            except EOFError:
                return
            if line.strip() == "{" and not multiline_input:
                multiline_input = True
                continue
            elif line.strip() == "}" and multiline_input:
                break
            elif multiline_input:
                inp += line + "\n"
            else:
                inp = line
                break

        print()
        return inp
=======
>>>>>>> UPDATED
```

```python
utils.py
<<<<<<< ORIGINAL
=======
def get_input(history_file, fnames):
    inp = ""
    multiline_input = False

    style = Style.from_dict({'': 'green'})

    while True:
        completer_instance = FileContentCompleter(fnames)
        if multiline_input:
            show = ". "
        else:
            show = "> "

        try:
            line = prompt(
                show,
                completer=completer_instance,
                history=FileHistory(history_file),
                style=style,
            )
        except EOFError:
            return
        if line.strip() == "{" and not multiline_input:
            multiline_input = True
            continue
        elif line.strip() == "}" and multiline_input:
            break
        elif multiline_input:
            inp += line + "\n"
        else:
            inp = line
            break

    print()
    return inp
>>>>>>> UPDATED
```

Now, update the call to `get_input` in `coder.py` to use the new `utils.get_input` function:

```python
coder.py
<<<<<<< ORIGINAL
        inp = self.get_input()
=======
        inp = utils.get_input(self.history_file, self.fnames)
>>>>>>> UPDATED
```
2023-05-09 10:09:42 -07:00
Paul Gauthier
64c3af37df WIP: Add pretty print to run_loop method. 2023-05-09 09:57:41 -07:00
Paul Gauthier
85fb17710f WIP: Add prompt_toolkit style and use it in prompt. 2023-05-09 09:54:50 -07:00
Paul Gauthier
240d1fa727 Remove custom style from prompt function call in coder.py to fix prompt_toolkit rendering issue.
# Context:
USER: Traceback (most recent call last):
  File "/Users/gauthier/Projects/chatgpt/./coder.py", line 496, in <module>
    status = main()
  File "/Users/gauthier/Projects/chatgpt/main.py", line 76, in main
    coder.run()
  File "/Users/gauthier/Projects/chatgpt/coder.py", line 206, in run
    self.run_loop()
  File "/Users/gauthier/Projects/chatgpt/coder.py", line 217, in run_loop
    inp = self.get_input()
  File "/Users/gauthier/Projects/chatgpt/coder.py", line 158, in get_input
    line = prompt(
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1420, in prompt
    return session.prompt(
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1035, in prompt
    return self.app.run(
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 961, in run
    return loop.run_until_complete(coro)
  File "/usr/local/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 875, in run_async
    return await _run_async(f)
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 733, in _run_async
    self._redraw()
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 548, in _redraw
    self.context.copy().run(run_in_context)
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 531, in run_in_context
    self.renderer.render(self, self.layout)
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/renderer.py", line 652, in render
    self.style.invalidation_hash() != self._last_style_hash
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/styles/style.py", line 400, in invalidation_hash
    return tuple(s.invalidation_hash() for s in self.styles)
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/styles/style.py", line 400, in <genexpr>
    return tuple(s.invalidation_hash() for s in self.styles)
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/styles/base.py", line 179, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/Users/gauthier/Projects/chatgpt/.venv/lib/python3.9/site-packages/prompt_toolkit/styles/base.py", line 179, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
AttributeError: 'str' object has no attribute 'invalidation_hash'

ASSISTANT: It seems like there is an issue with the `prompt_toolkit` library when trying to render the prompt. The error is related to the `invalidation_hash` method in the `style.py` file. To fix this issue, we can update the `get_input` method in the `coder.py` file to use a default style instead of the custom one.

Here's the change you need to make in the `coder.py` file:

```python
coder.py
<<<<<<< ORIGINAL
    line = prompt(
        show,
        completer=completer_instance,
        history=FileHistory(self.history_file),
        style="fg:green",
    )
=======
    line = prompt(
        show,
        completer=completer_instance,
        history=FileHistory(self.history_file),
    )
>>>>>>> UPDATED
```

This change removes the custom style (`style="fg:green"`) from the `prompt` function call, which should resolve the `AttributeError` you encountered.
2023-05-09 09:51:30 -07:00
Paul Gauthier
1c9bef484d add a trailing newline when replacing 2023-05-09 09:49:43 -07:00
Paul Gauthier
2de786a651 Change prompt text color to green.
# Context:
USER: have the prompt() call show the text in green
ASSISTANT: To change the text color of the prompt to green, you can use the `style` parameter in the `prompt()` function. Here's the change:

```python
coder.py
<<<<<<< ORIGINAL
                line = prompt(
                    show,
                    completer=completer_instance,
                    history=FileHistory(self.history_file),
                )
=======
                line = prompt(
                    show,
                    completer=completer_instance,
                    history=FileHistory(self.history_file),
                    style="fg:green",
                )
>>>>>>> UPDATED
```

This will make the text entered in the prompt appear green.
2023-05-09 09:48:59 -07:00
Paul Gauthier
8c88d0fca8 cleaned up filehistory 2023-05-09 09:48:17 -07:00
Paul Gauthier
1b28d24874 WIP: Refactor regex pattern in coder.py to include file extensions. 2023-05-09 09:44:15 -07:00
Paul Gauthier
6e9e384e5c Add FileHistory to prompt function calls in get_input method.
# Context:
USER: your change to the get_input method didn't work because you formatted it wrong. try again. no ...
ASSISTANT: I apologize for the confusion. Here's the updated change to the get_input method without using "...":

```python
coder.py
<<<<<<< ORIGINAL
                if multiline_input:
                    line = prompt(". ", completer=completer_instance)
                else:
                    line = prompt("> ", completer=completer_instance)
=======
                if multiline_input:
                    line = prompt(". ", completer=completer_instance, history=FileHistory(self.history_file))
                else:
                    line = prompt("> ", completer=completer_instance, history=FileHistory(self.history_file))
>>>>>>> UPDATED
```

This change adds the FileHistory to the prompt function calls in the get_input method.
2023-05-09 09:37:28 -07:00
Paul Gauthier
bc2c59368b Add FileHistory to get_input method in Coder class.
# Context:
USER: have get_input(self): use a FileHistory with the history_file
ASSISTANT: To use a FileHistory with the history_file in the get_input(self) method, we need to import FileHistory from prompt_toolkit.history and use it when calling the prompt function. Here's the change:

```python
coder.py
<<<<<<< ORIGINAL
from prompt_toolkit import prompt
from prompt_toolkit.completion import Completer, Completion
=======
from prompt_toolkit import prompt
from prompt_toolkit.completion import Completer, Completion
from prompt_toolkit.history import FileHistory
>>>>>>> UPDATED

...

class Coder:
    ...
    def get_input(self):
        ...
        while True:
            try:
                completer_instance = FileContentCompleter(self.fnames)
                if multiline_input:
                    line = prompt(". ", completer=completer_instance, history=FileHistory(self.history_file))
                else:
                    line = prompt("> ", completer=completer_instance, history=FileHistory(self.history_file))
            except EOFError:
                return
```
This change imports FileHistory and adds it as an argument to the prompt function calls in the get_input method.
2023-05-09 09:36:42 -07:00
Paul Gauthier
fe222d8943 fixed indent 2023-05-09 09:22:29 -07:00
Paul Gauthier
59e664e220 Connect FileContentCompleter to prompt() call in get_input() for autocompletion.`
# Context:
USER: connect the filecontentcompleter to the prompt() call in get_input, so that it autocompletes
ASSISTANT: To connect the `FileContentCompleter` to the `prompt()` call in the `get_input` method, you need to pass the `FileContentCompleter` instance as the `completer` argument in the `prompt()` function. Here's the change:

```python
coder.py
<<<<<<< ORIGINAL
            if multiline_input:
                line = prompt(". ")
            else:
                line = prompt("> ")
=======
            completer_instance = FileContentCompleter(self.fnames)
            if multiline_input:
                line = prompt(". ", completer=completer_instance)
            else:
                line = prompt("> ", completer=completer_instance)
>>>>>>> UPDATED
```

This change will enable autocompletion using the `FileContentCompleter` when you call `prompt()`.
2023-05-09 09:20:58 -07:00
Paul Gauthier
36d15d5f37 Add autocompletion based on the contents of the files in self.fnames.
# Context:
USER: have prompt_toolkit autocomplete based on the contents of the files in self.fnames
ASSISTANT: To add autocompletion based on the contents of the files in `self.fnames`, you can use the `Completer` class from `prompt_toolkit`. Here's how to implement it:

1. Import the necessary classes and functions from `prompt_toolkit`.
2. Create a custom completer class that inherits from `Completer`.
3. Override the `get_completions` method to provide completions based on the contents of the files.
4. Use the custom completer when calling the `prompt` function.

Here are the changes to the code:

```python
coder.py
<<<<<<< ORIGINAL
from prompt_toolkit import prompt
=======
from prompt_toolkit import prompt
from prompt_toolkit.completion import Completer, Completion
>>>>>>> UPDATED
```

```python
coder.py
<<<<<<< ORIGINAL
class Coder:
    fnames = dict()
    last_modified = 0
    repo = None
=======
class FileContentCompleter(Completer):
    def __init__(self, fnames):
        self.fnames = fnames

    def get_completions(self, document, complete_event):
        text = document.text_before_cursor
        words = text.split()
        if not words:
            return

        last_word = words[-1]
        for fname in self.fnames:
            with open(fname, "r") as f:
                content = f.read()
            for word in content.split():
                if word.startswith(last_word):
                    yield Completion(word, start_position=-len(last_word))

class Coder:
    fnames = dict()
    last_modified = 0
    repo = None
>>>>>>> UPDATED
```

```python
coder.py
<<<<<<< ORIGINAL
line = prompt("> ")
=======
completer = FileContentCompleter(self.fnames)
line = prompt("> ", completer=completer)
>>>>>>> UPDATED
```

These changes will add autocompletion based on the contents of the files in `self.fnames`.
2023-05-09 09:11:29 -07:00
Paul Gauthier
18b1809159 WIP: Comment out history file write in coder.py. 2023-05-09 09:09:45 -07:00
Paul Gauthier
b2e9eb05f0 WIP: Refactor Coder class to avoid readline dependency and fix input prompt. 2023-05-09 09:09:12 -07:00
Paul Gauthier
6ba8b7d41e Switch get_input() to use prompt_toolkit for input`.
# Context:
USER: switch get_input() to use prompt_toolkit for input
ASSISTANT: To switch `get_input()` to use `prompt_toolkit` for input, you'll need to install the `prompt_toolkit` library and replace the current input method with the `prompt_toolkit`'s `prompt` function. Here's how to make the change:

1. Install `prompt_toolkit` by adding it to your project's requirements or running `pip install prompt_toolkit`.

2. Import `prompt` from `prompt_toolkit` at the beginning of the `coder.py` file.

3. Replace the current input method in the `get_input()` function with the `prompt` function from `prompt_toolkit`.

Here are the changes to the `coder.py` file:

```python
coder.py
<<<<<<< ORIGINAL
import sys
import re
import readline
import traceback
=======
import sys
import re
import traceback
from prompt_toolkit import prompt
>>>>>>> UPDATED
```

```python
coder.py
<<<<<<< ORIGINAL
while True:
    try:
        if multiline_input:
            line = input(". ")
        else:
            line = input("> ")
    except EOFError:
        return
=======
while True:
    try:
        if multiline_input:
            line = prompt(". ")
        else:
            line = prompt("> ")
    except EOFError:
        return
>>>>>>> UPDATED
```

These changes will replace the standard `input()` function with the `prompt_toolkit`'s `prompt` function in the `get_input()` method.
2023-05-09 09:03:45 -07:00
Paul Gauthier
ef7e63a728 Add tests for strip_quoted_wrapping function in test_utils.py.
# Context:
USER: add tests for strip_quoted_wrapping
ASSISTANT: I will add tests for the `strip_quoted_wrapping` function in the `test_utils.py` file.

```python
test_utils.py
<<<<<<< ORIGINAL
if __name__ == "__main__":
    unittest.main()
=======
    def test_strip_quoted_wrapping(self):
        input_text = "filename.ext\n```\nWe just want this content\nNot the filename and triple quotes\n```"
        expected_output = "We just want this content\nNot the filename and triple quotes\n"
        result = strip_quoted_wrapping(input_text, "filename.ext")
        self.assertEqual(result, expected_output)

    def test_strip_quoted_wrapping_no_filename(self):
        input_text = "```\nWe just want this content\nNot the triple quotes\n```"
        expected_output = "We just want this content\nNot the triple quotes\n"
        result = strip_quoted_wrapping(input_text)
        self.assertEqual(result, expected_output)

    def test_strip_quoted_wrapping_no_wrapping(self):
        input_text = "We just want this content\nNot the triple quotes\n"
        expected_output = "We just want this content\nNot the triple quotes\n"
        result = strip_quoted_wrapping(input_text)
        self.assertEqual(result, expected_output)

if __name__ == "__main__":
    unittest.main()
>>>>>>> UPDATED
```

These tests cover cases when the input text has a filename, no filename, and no wrapping at all.
2023-05-09 08:44:35 -07:00
Paul Gauthier
941b1e50eb added docstring to strip_quoted_wrapping 2023-05-09 07:42:05 -07:00
Paul Gauthier
8a8bc3e244 Refactor replace_most_similar_chunk function and update test cases. 2023-05-09 07:39:37 -07:00
Paul Gauthier
17589d5241 Add test case for replace_most_similar_chunk with multi-line non-perfect match.
# Context:
USER: add another test case for replace_most_similar_chunk where it's not a perfect match, and part has more than 1 line
ASSISTANT: I will add a new test case to `test_utils.py` where the `part` has more than 1 line and it's not a perfect match.

```python
test_utils.py
<<<<<<< ORIGINAL
if __name__ == "__main__":
    unittest.main()
=======
    def test_replace_most_similar_chunk_not_perfect_match(self):
        whole = "This is a sample text.\nAnother line of text.\nYet another line."
        part = "sample text.\nAnother line"
        replace = "replaced text.\nModified line"
        expected_output = "This is a replaced text.\nModified line of text.\nYet another line."

        result = replace_most_similar_chunk(whole, part, replace)
        self.assertEqual(result, expected_output)

if __name__ == "__main__":
    unittest.main()
>>>>>>> UPDATED
```

This new test case checks if the `replace_most_similar_chunk` function can handle a non-perfect match with a multi-line `part`.
2023-05-09 07:36:07 -07:00
Paul Gauthier
350ba4574f Initial commit: Added new files to the git repo: test_utils.py 2023-05-09 07:35:01 -07:00
Paul Gauthier
106b72ad70 WIP: Remove print statement in do_replace function. 2023-05-09 07:33:58 -07:00
Paul Gauthier
fb12b73975 WIP: Refactor do_replace method to utils module and update references in coder module. 2023-05-09 07:31:26 -07:00
Paul Gauthier
11a5379d61 moved console print statements to indicate success or failure of applying edits. 2023-05-09 07:25:20 -07:00
Paul Gauthier
d6de4d3877 cleanup 2023-05-09 07:23:10 -07:00
Paul Gauthier
0b265d6608 colorize diff output 2023-05-09 07:17:57 -07:00
Paul Gauthier
4b56381382 strip() the before_text when looking for empty ORIGINAL 2023-05-09 07:10:40 -07:00
Paul Gauthier
cbfdd2a806 copy 2023-05-09 00:39:54 -07:00