Commit graph

10395 commits

Author SHA1 Message Date
Paul Gauthier
9b35a3e649 copy 2023-05-13 12:12:54 -07:00
Paul Gauthier
22ad1d906c copy 2023-05-13 12:12:31 -07:00
Paul Gauthier
0de32628f5 copy 2023-05-13 12:12:00 -07:00
Paul Gauthier
1dadfd9933 copy 2023-05-13 12:11:45 -07:00
Paul Gauthier
03ef18dee9 copy 2023-05-13 12:11:03 -07:00
Paul Gauthier
d3f7ec9020 copy 2023-05-13 12:10:51 -07:00
Paul Gauthier
b1c7c66a5e copy 2023-05-13 12:10:02 -07:00
Paul Gauthier
10a0a0bca0 copy 2023-05-13 12:07:40 -07:00
Paul Gauthier
909412c652 copy 2023-05-13 12:07:12 -07:00
Paul Gauthier
66dcbf3fbb copy 2023-05-13 12:04:04 -07:00
Paul Gauthier
3f932ce141 copy 2023-05-13 12:01:21 -07:00
Paul Gauthier
a61312630e copy 2023-05-13 12:00:25 -07:00
Paul Gauthier
3aa5db2bfa copy 2023-05-13 12:00:09 -07:00
Paul Gauthier
62abd9c202 copy 2023-05-13 11:58:06 -07:00
Paul Gauthier
d87b6f39c4 copy 2023-05-13 11:58:00 -07:00
Paul Gauthier
090ef0acd8 copy 2023-05-13 11:57:36 -07:00
Paul Gauthier
c087d6b4db copy 2023-05-13 11:52:49 -07:00
Paul Gauthier
50cef950cd copy 2023-05-13 11:52:28 -07:00
Paul Gauthier
53d9ff00b4 copy 2023-05-13 11:52:09 -07:00
Paul Gauthier
df9a3b3df6 copy 2023-05-13 11:51:25 -07:00
Paul Gauthier
cf1a1b92e1 copy 2023-05-13 11:47:12 -07:00
Paul Gauthier
e288cede8f copy 2023-05-13 10:50:17 -07:00
Paul Gauthier
f69525e573 copy 2023-05-13 10:31:46 -07:00
Paul Gauthier
04565b9181 wip: Changed the help message for using gpt-3.5-turbo model and updated the example docs. 2023-05-13 10:31:21 -07:00
Paul Gauthier
d1ae23be46 copy 2023-05-13 10:28:10 -07:00
Paul Gauthier
0436e1e76e Updated example names in README.md. 2023-05-13 10:27:29 -07:00
Paul Gauthier
337cfbd36a aider: Added an example demonstrating how to automatically update docs with Aider and GPT-4.
# Context:
USER: add the upd docs example to the readme
ASSISTANT: ```markdown
examples/README.md
<<<<<<< ORIGINAL
* [**CSS Exercise: Animation Dropdown Menu**](css-exercises.md): This example demonstrates how to complete a CSS exercise involving adding animation to a dropdown menu, creating a bounce illusion when the dropdown expands close to its final end state.
=======
* [**CSS Exercise: Animation Dropdown Menu**](css-exercises.md): This example demonstrates how to complete a CSS exercise involving adding animation to a dropdown menu, creating a bounce illusion when the dropdown expands close to its final end state.

* [**Automatically Update Docs with Aider and GPT-4**](update-docs.md): This example demonstrates how to use aider to automatically update documentation based on the latest version of the main() function in the code.
>>>>>>> UPDATED
```
2023-05-13 10:27:08 -07:00
Paul Gauthier
38a3b4309b Added update-docs example 2023-05-13 10:26:29 -07:00
Paul Gauthier
024f45e52f aider: Updated command line arguments in main() and updated README.md to accurately describe them.
# Context:
USER: the cmd line args in main() have been updated. update the readme.
ASSISTANT: ```markdown
README.md
<<<<<<< ORIGINAL
    parser.add_argument(
        "--input-history-file",
        metavar="INPUT_HISTORY_FILE",
        default=os.environ.get(f"{env_prefix}INPUT_HISTORY_FILE", ".aider.input.history"),
        help=(
            "Specify the chat input history file (default: .a
^C KeyboardInterrupt
USER: the cmd line args in main() have been updated. update the readme to accurately describe them.
ASSISTANT: ```markdown
README.md
<<<<<<< ORIGINAL
- `--history-file HISTORY_FILE`: Specify the chat input history file (default: .aider.history). Override the default with the environment variable `AIDER_HISTORY_FILE`.
- `--model MODEL`: Specify the model to use for the main chat (default: gpt-4). Override the default with the environment variable `AIDER_MODEL`.
- `-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 the default with the environment variable `AIDER_PRETTY` (default: 1 for enabled, 0 for disabled).
- `--show-diffs`: Show diffs when committing changes (default: False). Override the default with the environment variable `AIDER_SHOW_DIFFS` (default: 0 for False, 1 for True).
- `--no-auto-commits`: Disable auto commit of changes. Override the default with the environment variable `AIDER_AUTO_COMMITS` (default: 1 for enabled, 0 for disabled).
=======
- `--input-history-file INPUT_HISTORY_FILE`: Specify the chat input history file (default: .aider.input.history). Override the default with the environment variable `AIDER_INPUT_HISTORY_FILE`.
- `--chat-history-file CHAT_HISTORY_FILE`: Specify the chat history file (default: .aider.chat.history.md). Override the default with the environment variable `AIDER_CHAT_HISTORY_FILE`.
- `--model MODEL`: Specify the model to use for the main chat (default: gpt-4). Override the default with the environment variable `AIDER_MODEL`.
- `-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 the default 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 (debug).
- `--no-auto-commits`: Disable auto commit of changes. Override the default with the environment variable `AIDER_AUTO_COMMITS` (default: 1 for enabled, 0 for disabled).
- `--show-diffs`: Show diffs when committing changes (default: False). Override the default with the environment variable `AIDER_SHOW_DIFFS` (default: 0 for False, 1 for True).
- `--yes`: Always say yes to every confirmation (default: False).
>>>>>>> UPDATED
```
2023-05-13 10:23:41 -07:00
Paul Gauthier
43f045f24f copy 2023-05-13 10:18:53 -07:00
Paul Gauthier
5a9446aa24 copy 2023-05-13 10:17:44 -07:00
Paul Gauthier
c71d98ff82 cop 2023-05-13 10:15:56 -07:00
Paul Gauthier
fb319fe4d3 wip: Added notes to diffs about user adding main.py file and interrupting response. 2023-05-13 10:11:38 -07:00
Paul Gauthier
0110f86c7f wip: Added KeyboardInterrupt error message to coder.py. 2023-05-13 10:10:00 -07:00
Paul Gauthier
ffbbccd51d Commit 919cfc2: Replaced all self.console.print() calls with self.io.tool_error() calls with [red] removed from the string. 2023-05-13 10:04:19 -07:00
Paul Gauthier
eb4a1f5341 aider: Added the word "Commit" before each commit hash.
# Context:
USER: Add the word "Commit" before each commit hash
ASSISTANT: To add the word "Commit" before each commit hash, I will update the commit messages in the previous response. Here are the updated commit messages:

```plaintext
examples/hello-world-flask.md
<<<<<<< ORIGINAL
_Applied edit to app.py_
_414c394 aider: Added a `/hello` endpoint that returns "Hello, World!" to the Flask app._
=======
_Applied edit to app.py_
Commit 414c394 aider: Added a `/hello` endpoint that returns "Hello, World!" to the Flask app._
>>>>>>> UPDATED
```

^C KeyboardInterrupt
USER: keep the leading _ for italics
ASSISTANT: I apologize for the confusion. Here are the updated commit messages with the word "Commit" added before each commit hash while keeping the leading underscores for italics:

```plaintext
examples/hello-world-flask.md
<<<<<<< ORIGINAL
_Applied edit to app.py_
_414c394 aider: Added a `/hello` endpoint that returns "Hello, World!" to the Flask app._
=======
_Applied edit to app.py_
_Commit 414c394 aider: Added a `/hello` endpoint that returns "Hello, World!" to the Flask app._
>>>>>>> UPDATED
```

```plaintext
examples/hello-world-flask.md
<<<<<<< ORIGINAL
_Applied edit to app.py_
_0872c51 aider: Added an endpoint `/add/<int:num1>/<int:num2>` that returns the sum of the two numbers._
=======
_Applied edit to app.py_
_Commit 0872c51 aider: Added an endpoint `/add/<int:num1>/<int:num2>` that returns the sum of the two numbers._
>>>>>>> UPDATED
```

```plaintext
examples/hello-world-flask.md
<<<<<<< ORIGINAL
_Applied edit to app.py_
_163fba8 aider: Added a `/fibonacci/X` endpoint that returns the Xth number in the Fibonacci sequence._
=======
_Applied edit to app.py_
_Commit 163fba8 aider: Added a `/fibonacci/X` endpoint that returns the Xth number in the Fibonacci sequence._
>>>>>>> UPDATED
```

```plaintext
examples/hello-world-flask.md
<<<<<<< ORIGINAL
_Applied edit to app.py_
_eab6620 aider: Removed the `/hello` endpoint from the Flask app._
=======
_Applied edit to app.py_
_Commit eab6620 aider: Removed the `/hello` endpoint from the Flask app._
>>>>>>> UPDATED
```
2023-05-13 10:03:28 -07:00
Paul Gauthier
2d6b7eb978 Changed the project name to "Aider". 2023-05-13 09:55:51 -07:00
Paul Gauthier
e3f523d427 aider: Fixed cmd_undo function to catch GitCommandError exception when trying to get the remote head of the current branch using origin/<branch_name> instead of origin/HEAD.
# Context:
USER: README.md> /undo

Traceback (most recent call last):
  File "/Users/gauthier/Projects/aider/.venv/bin/aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/gauthier/Projects/aider/aider/main.py", line 113, in main
    coder.run()
  File "/Users/gauthier/Projects/aider/aider/coder.py", line 178, in run
    new_user_message = self.run_loop()
                       ^^^^^^^^^^^^^^^
  File "/Users/gauthier/Projects/aider/aider/coder.py", line 223, in run_loop
    return self.commands.run(inp)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gauthier/Projects/aider/aider/commands.py", line 62, in run
    return self.do_run(matching_commands[0][1:], rest_inp)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gauthier/Projects/aider/aider/commands.py", line 44, in do_run
    return cmd_method(args)
           ^^^^^^^^^^^^^^^^
  File "/Users/gauthier/Projects/aider/aider/commands.py", line 96, in cmd_undo
    remote_head = self.coder.repo.git.rev_parse("origin/HEAD")
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gauthier/Projects/aider/.venv/lib/python3.11/site-packages/git/cmd.py", line 741, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gauthier/Projects/aider/.venv/lib/python3.11/site-packages/git/cmd.py", line 1315, in _call_process
    return self.execute(call, **exec_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gauthier/Projects/aider/.venv/lib/python3.11/site-packages/git/cmd.py", line 1109, in execute
    raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git rev-parse origin/HEAD
  stdout: 'origin/HEAD'
  stderr: 'fatal: ambiguous argument 'origin/HEAD': unknown revision or path not in the working tree.

ASSISTANT: It seems like there is an issue with the `cmd_undo` function in the `aider/commands.py` file. The error is caused by the `self.coder.repo.git.rev_parse("origin/HEAD")` line. To fix this issue, we can check if the remote "origin" exists before trying to get the remote head.

Here's the change I suggest:

```python
aider/commands.py
<<<<<<< ORIGINAL
        if has_origin:
            remote_head = self.coder.repo.git.rev_parse("origin/HEAD")
=======
        if has_origin:
            try:
                remote_head = self.coder.repo.git.rev_parse("origin/HEAD")
            except git.exc.GitCommandError:
                self.io.tool_error("Error: Unable to get the remote 'origin/HEAD'.")
                return
>>>>>>> UPDATED
```

This change will catch the `GitCommandError` exception and display an error message instead of raising
^C KeyboardInterrupt
USER: the error occurred on a repo with an origin. Is `origin/HEAD` a valid way to check the head of the current branch's remote?
ASSISTANT: I apologize for the confusion. You are correct that `origin/HEAD` is not the proper way to check the head of the current branch's remote. Instead, we should use `origin/<branch_name>` to get the remote head of the current branch. Here's the updated change:

```python
aider/commands.py
<<<<<<< ORIGINAL
        if has_origin:
            remote_head = self.coder.repo.git.rev_parse("origin/HEAD")
=======
        if has_origin:
            current_branch = self.coder.repo.active_branch.name
            try:
                remote_head = self.coder.repo.git.rev_parse(f"origin/{current_branch}")
            except git.exc.GitCommandError:
                self.io.tool_error(f"Error: Unable to get the remote 'origin/{current_branch}'.")
                return
>>>>>>> UPDATED
```

This change will get the name of the current active branch and use it to check the remote head of the current branch.
2023-05-13 09:55:00 -07:00
Paul Gauthier
51abe3d24f aider: Changed the title to "aider" in lowercase.
# Context:
USER: change the title to "aider" in lowercase
ASSISTANT: ```markdown
README.md
<<<<<<< ORIGINAL
# Aider
=======
# aider
>>>>>>> UPDATED
```
2023-05-13 09:52:45 -07:00
Paul Gauthier
83c47eef62 aider: Added conditional check to see if the repo has an origin before comparing local and remote commit hashes in cmd_undo.
# Context:
USER: not all repos have an origin. only do that check if the repo does
ASSISTANT: To check if the repo has an origin, we can use `self.coder.repo.remotes` to see if there is a remote named "origin". We will add a conditional check before comparing the local and remote commit hashes.

```python
aider/commands.py
<<<<<<< ORIGINAL
    def cmd_undo(self, args):
        "Undo the last git commit if it was done by aider"
        if not self.coder.repo:
            self.io.tool_error("No git repository found.")
            return

        if self.coder.repo.is_dirty():
            self.io.tool_error("The repository has uncommitted changes. Please commit or stash them before undoing.")
            return

        local_head = self.coder.repo.git.rev_parse("HEAD")
        remote_head = self.coder.repo.git.rev_parse("origin/HEAD")

        if local_head == remote_head:
            self.io.tool_error("The last commit has already been pushed to the origin. Undoing is not possible.")
            return

        last_commit = self.coder.repo.head.commit
=======
    def cmd_undo(self, args):
        "Undo the last git commit if it was done by aider"
        if not self.coder.repo:
            self.io.tool_error("No git repository found.")
            return

        if self.coder.repo.is_dirty():
            self.io.tool_error("The repository has uncommitted changes. Please commit or stash them before undoing.")
            return

        local_head = self.coder.repo.git.rev_parse("HEAD")
        has_origin = any(remote.name == "origin" for remote in self.coder.repo.remotes)

        if has_origin:
            remote_head = self.coder.repo.git.rev_parse("origin/HEAD")
            if local_head == remote_head:
                self.io.tool_error("The last commit has already been pushed to the origin. Undoing is not possible.")
                return

        last_commit = self.coder.repo.head.commit
>>>>>>> UPDATED
```
2023-05-13 09:51:57 -07:00
Paul Gauthier
84b3a1756d aider: Added check to prevent undoing a commit that has already been pushed to origin.
# Context:
USER: also check to make sure the commit hasn't already been pushed to origin
ASSISTANT: To check if the commit has already been pushed to the origin, we can compare the local and remote commit hashes. We will add a check using `self.coder.repo.git.rev_parse("HEAD")` and `self.coder.repo.git.rev_parse("origin/HEAD")` before performing the undo operation.

```python
aider/commands.py
<<<<<<< ORIGINAL
    def cmd_undo(self, args):
        "Undo the last git commit if it was done by aider"
        if not self.coder.repo:
            self.io.tool_error("No git repository found.")
            return

        if self.coder.repo.is_dirty():
            self.io.tool_error("The repository has uncommitted changes. Please commit or stash them before undoing.")
            return

        last_commit = self.coder.repo.head.commit
=======
    def cmd_undo(self, args):
        "Undo the last git commit if it was done by aider"
        if not self.coder.repo:
            self.io.tool_error("No git repository found.")
            return

        if self.coder.repo.is_dirty():
            self.io.tool_error("The repository has uncommitted changes. Please commit or stash them before undoing.")
            return

        local_head = self.coder.repo.git.rev_parse("HEAD")
        remote_head = self.coder.repo.git.rev_parse("origin/HEAD")

        if local_head == remote_head:
            self.io.tool_error("The last commit has already been pushed to the origin. Undoing is not possible.")
            return

        last_commit = self.coder.repo.head.commit
>>>>>>> UPDATED
```
2023-05-13 09:48:30 -07:00
Paul Gauthier
e74c90037c removed nested call to io.tool_error 2023-05-13 09:47:08 -07:00
Paul Gauthier
2b6ea21a0b aider: Added check to ensure the repo isn't dirty before undoing.
# Context:
USER: in /undo make sure the repo isn't dirty before undoing
ASSISTANT: To ensure the repo isn't dirty before undoing, we will add a check using `self.coder.repo.is_dirty()` before performing the undo operation.

```python
aider/commands.py
<<<<<<< ORIGINAL
    def cmd_undo(self, args):
        "Undo the last git commit if it was done by aider"
        if not self.coder.repo:
            self.io.tool_error("No git repository found.")
            return

        last_commit = self.coder.repo.head.commit
=======
    def cmd_undo(self, args):
        "Undo the last git commit if it was done by aider"
        if not self.coder.repo:
            self.io.tool_error("No git repository found.")
            return

        if self.coder.repo.is_dirty():
            self.io.tool_error("The repository has uncommitted changes. Please commit or stash them before undoing.")
            return

        last_commit = self.coder.repo.head.commit
>>>>>>> UPDATED
```
2023-05-13 09:46:21 -07:00
Paul Gauthier
981710ca16 Bumped version to 0.3.0 in setup.py. 2023-05-13 09:44:22 -07:00
Paul Gauthier
d6d6ce8d1f copy 2023-05-13 09:42:57 -07:00
Paul Gauthier
90e09a3f4e copy 2023-05-13 09:42:22 -07:00
Paul Gauthier
8aaa42e6ef aider: Added CSS exercise example to README files.
# Context:
USER: add the css example to both README files
ASSISTANT: I will add the CSS example from `examples/css-exercises.md` to both `README.md` and `examples/README.md` files.

```markdown
README.md
<<<<<<< ORIGINAL
* [**Semantic Search & Replace**](examples/semantic-search-replace.md): This example showcases aider's ability to perform semantic search and replace operations in code, dealing with various formatting and semantic differences in the function calls that it updates.
=======
* [**Semantic Search & Replace**](examples/semantic-search-replace.md): This example showcases aider's ability to perform semantic search and replace operations in code, dealing with various formatting and semantic differences in the function calls that it updates.
* [**CSS Exercise: Animation Dropdown Menu**](examples/css-exercises.md): This example demonstrates how to complete a CSS exercise involving adding animation to a dropdown menu, creating a bounce illusion when the dropdown expands close to its final end state.
>>>>>>> UPDATED
```

```markdown
examples/README.md
<<<<<<< ORIGINAL
* [**Semantic Search & Replace**](semantic-search-replace.md): This example showcases aider's ability to perform semantic search and replace operations in code, dealing with various formatting and semantic differences in the function calls that it updates.
=======
* [**Semantic Search & Replace**](semantic-search-replace.md): This example showcases aider's ability to perform semantic search and replace operations in code, dealing with various formatting and semantic differences in the function calls that it updates.
* [**CSS Exercise: Animation Dropdown Menu**](css-exercises.md): This example demonstrates how to complete a CSS exercise involving adding animation to a dropdown menu, creating a bounce illusion when the dropdown expands close to its final end state.
>>>>>>> UPDATED
```

These changes add the CSS exercise example to both `README.md` and `examples/README.md` files.
2023-05-13 09:08:06 -07:00
Paul Gauthier
8771c08cf1 added css exercises 2023-05-13 09:06:35 -07:00
Paul Gauthier
e629f0c123 numbers to bullets 2023-05-13 08:56:52 -07:00
Paul Gauthier
490ee86637 wip: Updated file paths for example code in README. 2023-05-13 08:56:10 -07:00