Commit graph

875 commits

Author SHA1 Message Date
Paul Gauthier
f28fc5b2b1 Changed command description for cmd_run. 2023-05-18 10:15:18 -07:00
Paul Gauthier
a525a1b543 Ask to add /run output to the chat 2023-05-18 10:13:50 -07:00
Paul Gauthier
0ade98dfff removed line numbers 2023-05-18 10:07:56 -07:00
Paul Gauthier
261f50c3ba removed line numbers 2023-05-18 10:07:39 -07:00
Paul Gauthier
01aafe1265 aider: Fixed indentation of cmd_run function in aider/commands.py.
# Context:
USER: remove all the line numbers fro the start of the lines, restoring proper indentation. only edit the lines that have line numbers.
ASSISTANT: ```python
aider/commands.py
<<<<<<< ORIGINAL
228     def cmd_run(self, args):
229         "Run the supplied command in a subprocess and combine stdout and stderr into a single string"
230         try:
231             parsed_args = shlex.split(args)
232             result = subprocess.run(parsed_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
233             combined_output = result.stdout
233             print(combined_output)
234         except Exception as e:
235             self.io.tool_error(f"Error running command: {e}")
=======
    def cmd_run(self, args):
        "Run the supplied command in a subprocess and combine stdout and stderr into a single string"
        try:
            parsed_args = shlex.split(args)
            result = subprocess.run(parsed_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
            combined_output = result.stdout
            print(combined_output)
        except Exception as e:
            self.io.tool_error(f"Error running command: {e}")
>>>>>>> UPDATED
```
2023-05-18 10:06:38 -07:00
Paul Gauthier
07da14d3c7 make line numbers optional 2023-05-18 10:04:13 -07:00
Paul Gauthier
7c807c8c53 aider: Changed cmd_run method to intermingle stdout and stderr using subprocess.PIPE for both and setting stderr=subprocess.STDOUT.
# Context:
USER: rather than concatenating stdin and stderr, can we get them intermingled like they would be shown in normal terminal output
ASSISTANT: Yes, you can intermingle stdout and stderr like they would be shown in normal terminal output by using the `subprocess.PIPE` for both stdout and stderr, and setting `stderr=subprocess.STDOUT`. We will modify the `cmd_run` method in the `aider/commands.py` file to implement this change.

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

```python
aider/commands.py
<<<<<<< ORIGINAL
231             parsed_args = shlex.split(args)
232             result = subprocess.run(parsed_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
233             combined_output = result.stdout + result.stderr
=======
231             parsed_args = shlex.split(args)
232             result = subprocess.run(parsed_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
233             combined_output = result.stdout
>>>>>>> UPDATED
```

These changes set `stderr=subprocess.STDOUT` in the `subprocess.run()` call, which will intermingle stdout and stderr like they would be shown in normal terminal output.
2023-05-18 10:02:44 -07:00
Paul Gauthier
aaf8c9e811 aider: Refactored cmd_run method to use shlex.split() instead of args.split() to correctly parse arguments, respecting quotes and other special characters.
# Context:
USER: is there a better way to parse args than args.split(), like a shell would, to respect quotes, etc
ASSISTANT: Yes, you can use the `shlex` module to split the arguments like a shell would, respecting quotes and other special characters. We will modify the `cmd_run` method in the `aider/commands.py` file to use `shlex.split()` instead of `args.split()`.

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

```python
aider/commands.py
<<<<<<< ORIGINAL
  3 import subprocess
=======
  3 import subprocess
  4 import shlex
>>>>>>> UPDATED
```

```python
aider/commands.py
<<<<<<< ORIGINAL
230         try:
231             result = subprocess.run(args.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
=======
230         try:
231             parsed_args = shlex.split(args)
232             result = subprocess.run(parsed_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
>>>>>>> UPDATED
```

These changes import the `shlex` module and replace `args.split()` with `shlex.split(args)` in the `cmd_run` method. This will correctly parse the arguments, respecting quotes and other special characters.
2023-05-18 10:01:24 -07:00
Paul Gauthier
f21857655e aider: Added cmd_run command to run a supplied command in a subprocess and combine stdout and stderr into a single string.
# Context:
USER: add a new cmd_run which runs the supplied line in a subprocess and collects stdout and stderr into strings
ASSISTANT: To add the `cmd_run` command, we will modify the `aider/commands.py` file. We will import the `
^C KeyboardInterrupt
USER: add a new cmd_run which runs the supplied line in a subprocess. combine stdout and stderr into a single string. print that.
ASSISTANT: To add the `cmd_run` command, we will modify the `aider/commands.py` file. We will import the `subprocess` module and create a new method called `cmd_run`. This method will run the supplied command in a subprocess, combine stdout and stderr into a single string, and print the result.

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

```python
aider/commands.py
<<<<<<< ORIGINAL
  1 import os
  2 import git
=======
  1 import os
  2 import git
  3 import subprocess
>>>>>>> UPDATED
```

```python
aider/commands.py
<<<<<<< ORIGINAL
228     def cmd_ls(self, args):
229         "List all known files and those included in the chat session"
230
231         files = self.coder.get_all_relative_files()
=======
228     def cmd_run(self, args):
229         "Run the supplied command in a subprocess and combine stdout and stderr into a single string"
230         try:
231             result = subprocess.run(args.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
232             combined_output = result.stdout + result.stderr
233             print(combined_output)
234         except Exception as e:
235             self.io.tool_error(f"Error running command: {e}")
236
237     def cmd_ls(self, args):
238         "List all known files and those included in the chat session"
239
240         files = self.coder.get_all_relative_files()
>>>>>>> UPDATED
```

These changes import the `subprocess` module, add the `cmd_run` method, and handle running the command and printing the combined stdout and stderr.
2023-05-18 09:59:48 -07:00
Paul Gauthier
33ae950467 Merge branch 'main' into pre-commit 2023-05-18 09:56:00 -07:00
Paul Gauthier
06a58b84bb noop 2023-05-18 09:55:50 -07:00
Paul Gauthier
4cbdb9b9ad Added a method to check if input is a command. 2023-05-18 09:54:54 -07:00
Paul Gauthier
271b0c837b Added a conditional to display a message only if input is not empty. 2023-05-18 08:54:19 -07:00
Paul Gauthier
891d5b2263 aider: Added line numbers to the output of the get_quoted_file function.
# Context:
USER: git get_files_content prefix each line with a line number, starting at 1, padded out like '  1'
ASSISTANT: To add line numbers to the `get_files_content` method, we will modify the method in the `aider/coder.py` file. We will read the file content line by line and add the line number with padding to each line.

Here's the change:

```python
aider/coder.py
<<<<<<< ORIGINAL
    def get_files_content(self, fnames=None):
        if not fnames:
            fnames = self.abs_fnames

        prompt = ""
        for fname in fnames:
            relative_fname = self.get_rel_fname(fname)
            prompt += utils.quoted_file(fname, relative_fname)
        return prompt
=======
    def get_files_content(self, fnames=None):

^C KeyboardInterrupt
USER: sorry, in get_quoted_file prefix each line with a line number, starting at 1, padded out like '  1'
ASSISTANT:
^C KeyboardInterrupt
USER: Please note that I shared content of these additional files: aider/utils.py
ASSISTANT: To add line
^C KeyboardInterrupt
USER: in get_quoted_file prefix each line with a line number, starting at 1, padded out like '  1'
ASSISTANT: To add line numbers to the `get_quoted_file` function in the `aider/utils.py` file, we will read the file content line by line and add the line number with padding to each line.

Here's the change:

```python
aider/utils.py
<<<<<<< ORIGINAL
def quoted_file(fname, display_fname):
    prompt = "\n"
    prompt += display_fname
    prompt += "\n```\n"
    prompt += Path(fname).read_text()
    prompt += "\n```\n"
    return prompt
=======
def quoted_file(fname, display_fname):
    prompt = "\n"
    prompt += display_fname
    prompt += "\n```\n"
    file_content = Path(fname).read_text()
    lines = file_content.splitlines()
    for i, line in enumerate(lines, start=1):
        prompt += f"{i:3d} {line}\n"
    prompt += "```\n"
    return prompt
>>>>>>> UPDATED
```

This change will add line numbers to the output of the `get_quoted_file` function, starting at 1 and padded out like '  1'.
2023-05-18 07:00:50 -07:00
Paul Gauthier
8913eb5066 aider: Removed unused import statement for 'sys' in tests/test_main.py.
# Context:
USER: tests/test_main.py:2:1: F401 'sys' imported but unused
import sys
^

ASSISTANT: To fix the unused import issue, you can remove the import statement for 'sys' in the `tests/test_main.py` file.

```python
tests/test_main.py
<<<<<<< ORIGINAL
import sys
=======
>>>>>>> UPDATED
```
2023-05-17 18:26:43 -07:00
Paul Gauthier
943084fba2 aider: Removed unused imports in aider/io.py.
# Context:
USER: aider/io.py:12:1: F401 'time' imported but unused
import time
^
aider/io.py:13:1: F401 'random' imported but unused
import random
^

ASSISTANT: I see that there are unused imports in the `aider/io.py` file. I will remove them.

```python
aider/io.py
<<<<<<< ORIGINAL
import time
import random
=======
>>>>>>> UPDATED
```
2023-05-17 18:26:15 -07:00
Paul Gauthier
d5f2bef29e aider: Import git module in aider/commands.py.
# Context:
USER: aider/commands.py:101:20: F821 undefined name 'git'
            except git.exc.GitCommandError:
                   ^

ASSISTANT: It seems like the `git` module is not imported in the `aider/commands.py` file. To fix this issue, we need to import the `git` module at the beginning of the file.

Here's the change to import the `git` module:

```python
aider/commands.py
<<<<<<< ORIGINAL
import os
from rich.prompt import Confirm
from prompt_toolkit.completion import Completion
from aider import prompts
=======
import os
import git
from rich.prompt import Confirm
from prompt_toolkit.completion import Completion
from aider import prompts
>>>>>>> UPDATED
```
2023-05-17 18:25:47 -07:00
Paul Gauthier
6e83df4c8d aider: Removed unused import of rich.text.Text in aider/commands.py.
# Context:
USER: aider/commands.py:2:1: F401 'rich.text.Text' imported but unused
from rich.text import Text
^

ASSISTANT: I will remove the unused import from the `aider/commands.py` file.

```python
aider/commands.py
<<<<<<< ORIGINAL
from rich.text import Text
from rich.prompt import Confirm
=======
from rich.prompt import Confirm
>>>>>>> UPDATED
```
2023-05-17 18:25:03 -07:00
Paul Gauthier
9a413d351d black formatting 2023-05-17 18:24:35 -07:00
Paul Gauthier
3c26f90269 aider: Added --show-source argument to flake8 hook in .pre-commit-config.yaml.
# Context:
USER: can we make flake8 output the actual lines that have each error?
ASSISTANT: Yes, we can modify the `.pre-commit-config.yaml` file to include the `--show-source` argument for flake8. This will show the source code lines that have errors.

Here's the change:

```yaml
.pre-commit-config.yaml
<<<<<<< ORIGINAL
  - repo: https://github.com/pycqa/flake8
    rev: 6.0.0
    hooks:
      - id: flake8
=======
  - repo: https://github.com/pycqa/flake8
    rev: 6.0.0
    hooks:
      - id: flake8
        args: ["--show-source"]
>>>>>>> UPDATED
```
2023-05-17 17:55:40 -07:00
Paul Gauthier
bdae74a9a8 Ask the user to retry their cmd if we interrupt with an autocommit 2023-05-17 16:19:15 -07:00
Paul Gauthier
cc0ee034f4 aider: Added a check to ensure that part appears in whole exactly once in try_dotdotdots.
# Context:
USER: in try_dotdotdots, after checking that part is in whole add a check that part is in whole exactly 1 time
ASSISTANT: ```python
aider/utils.py
<<<<<<< ORIGINAL
        if part not in whole:
            raise ValueError("No perfect matching chunk in edit block with ...")

        whole = whole.replace(part, replace)
=======
        if whole.count(part) != 1:
            raise ValueError("No perfect matching chunk in edit block with ... or part appears more than once")

        whole = whole.replace(part, replace, 1)
>>>>>>> UPDATED
```
2023-05-17 16:15:09 -07:00
Paul Gauthier
de69a3095a aider: Removed all the save_stdin stuff.
# Context:
USER: remove all the save_stdin stuff
ASSISTANT: ```python
tests/test_main.py
<<<<<<< ORIGINAL
            save_stdin = sys.stdin
            sys.stdin = pipe_input
            main([], input=pipe_input, output=DummyOutput())
            sys.stdin = save_stdin
=======
            main([], input=pipe_input, output=DummyOutput())
>>>>>>> UPDATED
```

```python
tests/test_main.py
<<<<<<< ORIGINAL
            save_stdin = sys.stdin
            sys.stdin = pipe_input
            main(["foo.txt"], input=pipe_input, output=DummyOutput())
            sys.stdin = save_stdin
=======
            main(["foo.txt"], input=pipe_input, output=DummyOutput())
>>>>>>> UPDATED
```

```python
tests/test_main.py
<<<<<<< ORIGINAL
            save_stdin = sys.stdin
            sys.stdin = pipe_input
            main(["--yes", "foo.txt"], input=pipe_input, output=DummyOutput())
            sys.stdin = save_stdin
=======
            main(["--yes", "foo.txt"], input=pipe_input, output=DummyOutput())
>>>>>>> UPDATED
```
2023-05-17 16:13:01 -07:00
Paul Gauthier
2e53e59cf3 aider: Changed print statement to show actual repo directory instead of working tree.
# Context:
USER: after Using git repo print the actual repo dir, not the working tree
ASSISTANT: To print the actual repo directory instead of the working tree, you can use the `git rev-parse --git-dir` command. I need to see the relevant code file where you want to implement this change.
^C KeyboardInterrupt
USER: Please note that I shared content of these additional files: aider/coder.py
ASSISTANT: I apologize for the oversight. Here's the change to print the actual repo directory instead of the working tree in the `aider/coder.py` file:

```python
aider/coder.py
<<<<<<< ORIGINAL
        if self.repo:
            self.io.tool("Using git repo:", self.root)
=======
        if self.repo:
            self.io.tool("Using git repo:", self.repo.git_dir)
>>>>>>> UPDATED
```

This change will print the actual repo directory when a suitable git repo is found.
2023-05-17 16:11:40 -07:00
Paul Gauthier
d0c729469d Added logging for when a suitable git repo is found. 2023-05-17 16:10:38 -07:00
Paul Gauthier
a120063d45 updated demo gif 2023-05-17 15:42:30 -07:00
Paul Gauthier
4ce6e279d3 Removed the canned_input method and commented out related code. 2023-05-17 15:24:40 -07:00
Paul Gauthier
7dc406d0b4 Print aider in lowercase 2023-05-17 15:22:34 -07:00
Paul Gauthier
a9511b85b6 Added log_only parameter to io.tool function call. 2023-05-17 15:21:21 -07:00
Paul Gauthier
bca4674e07 aider: Added a log_only parameter to tool() to allow emitting only to the log.
# Context:
USER: add a log_only=False param to tool() which only emits to the log, not to the scren
ASSISTANT: ```python
aider/io.py
<<<<<<< ORIGINAL
    def tool(self, *messages):
        if messages:
            hist = " ".join(messages)
            hist = f"{hist.strip()}"
            self.append_chat_history(hist, linebreak=True, blockquote=True)

        messages = list(map(Text, messages))
        self.console.print(*messages)
=======
    def tool(self, *messages, log_only=False):
        if messages:
            hist = " ".join(messages)
            hist = f"{hist.strip()}"
            self.append_chat_history(hist, linebreak=True, blockquote=True)

        if not log_only:
            messages = list(map(Text, messages))
            self.console.print(*messages)
>>>>>>> UPDATED
```
2023-05-17 15:20:52 -07:00
Paul Gauthier
fc1dac4ac3 log the cmd line to the chat history 2023-05-17 13:47:34 -07:00
Paul Gauthier
6ea9085eec updated md chat log format 2023-05-17 13:45:27 -07:00
Paul Gauthier
11c0dd89d9 Renamed getinput -> io 2023-05-17 13:41:58 -07:00
Paul Gauthier
7b04f5ab8d link to the open source repos in transcripts 2023-05-17 09:55:54 -07:00
Paul Gauthier
6bc6aa240b copy 2023-05-16 10:15:40 -07:00
Paul Gauthier
5429ed9e62 copy 2023-05-16 06:51:40 -07:00
Paul Gauthier
7074db7ea4 better title/desc for homepage 2023-05-16 06:48:20 -07:00
Paul Gauthier
1575e885b7 title 2023-05-16 06:41:03 -07:00
Paul Gauthier
c499b5d8ed page.url 2023-05-16 06:39:49 -07:00
Paul Gauthier
3b69df6a82 undo 2023-05-16 06:33:56 -07:00
Paul Gauthier
72b7721fbd aider: Added a trailing slash to site.baseurl in if statement.
# Context:
USER: in the if page.url == site.baseurl, add a trailing slash to site.baseurl
ASSISTANT: ```html
_layouts/default.html
<<<<<<< ORIGINAL
      {% if page.url == site.baseurl %}
=======
      {% if page.url == site.baseurl | append: '/' %}
>>>>>>> UPDATED
```
2023-05-16 06:31:50 -07:00
Paul Gauthier
a716d3fb6f Updated README.md with a new project description. 2023-05-16 06:29:46 -07:00
Paul Gauthier
263988a27c aider: Added if statement to always display "aider" and "aider is GPT-4 powered coding in your terminal" on home page.
# Context:
USER: add an if statement, so the home page always has <h1>aider</h1> and <h2>aider is GPT-4 powered coding in your terminal</h2>
ASSISTANT: ```html
_layouts/default.html
<<<<<<< ORIGINAL
      <h1 class="project-name">{{ page.title | default: site.title | default: site.github.repository_name }}</h1>
      <h2 class="project-tagline">{{ page.description | default: site.description | default: site.github.project_tagline }}</h2>
=======
      {% if page.url == site.baseurl %}
      <h1 class="project-name">aider</h1>
      <h2 class="project-tagline">aider is GPT-4 powered coding in your terminal</h2>
      {% else %}
      <h1 class="project-name">{{ page.title | default: site.title | default: site.github.repository_name }}</h1>
      <h2 class="project-tagline">{{ page.description | default: site.description | default: site.github.project_tagline }}</h2>
      {% endif %}
>>>>>>> UPDATED
```
2023-05-16 06:29:28 -07:00
Paul Gauthier
2a1b2f8163 wip: Changed README.md header to be more concise. 2023-05-16 06:27:43 -07:00
Paul Gauthier
7c746d27b8 copy 2023-05-16 06:26:07 -07:00
Paul Gauthier
ba3172ba6c revert to old title/desc 2023-05-16 05:49:20 -07:00
Paul Gauthier
defa8717e4 wip: Updated project description and fixed config file paths and descriptions. 2023-05-16 05:44:52 -07:00
Paul Gauthier
9471024dd0 Updated descriptions for home and examples sections in _config.yml. 2023-05-16 05:40:39 -07:00
Paul Gauthier
cd93146ed3 aider: Added a scope to set a custom description for the home page in _config.yml.
# Context:
USER: how do i add a scope that sets the description just for the home page?
ASSISTANT: To add a scope that sets the description just for the home page, you'll need to modify the `_config.yml` file. You can define a new scope with a specific path pointing to the home page (usually `index.md` or `index.html`).

Here's how to add a scope with a custom description for the home page:

```yaml
_config.yml
<<<<<<< ORIGINAL
theme: jekyll-theme-cayman

defaults:
  - scope:
      path: "examples"
      type: "pages"
    values:
      description: "This is a custom description for the examples section."
=======
theme: jekyll-theme-cayman

defaults:
  - scope:
      path: "examples"
      type: "pages"
    values:
      description: "This is a custom description for the examples section."
  - scope:
      path: "index.md" # or "index.html" if your home page is an HTML file
      type: "pages"
    values:
      description: "This is a custom description for the home page."
>>>>>>> UPDATED
```

This will apply the custom description to the home page. Make sure to replace `"index.md"` with `"index.html"` if your home page is an HTML file.
2023-05-16 05:39:59 -07:00
Paul Gauthier
d0a51a85d0 aider: Added a scope with a custom description for the examples section in _config.yml.
# Context:
USER: can i use scope to apply a different description to different parts of the site?
ASSISTANT: Yes, you can use the `scope` feature in Jekyll to apply different descriptions to different parts of the site. You'll need to modify the `_config.yml` file to define the scopes and their respective descriptions.

Here's a step-by-step guide to achieve this:

1. In the `_config.yml` file, add a new `defaults` section.
2. Define the scope by specifying the `path` and `type` attributes.
3. Set the `values` attribute to include the `description` key with the desired description text.

Here's an example of how to add a scope with a custom description for the `examples` directory:

```yaml
_config.yml
<<<<<<< ORIGINAL
theme: jekyll-theme-cayman
=======
theme: jekyll-theme-cayman

defaults:
  - scope:
      path: "examples"
      type: "pages"
    values:
      description: "This is a custom description for the examples section."
>>>>>>> UPDATED
```

This will apply the custom description to all pages within the `examples` directory. You can add more scopes for other directories or specific pages by following the same pattern.
2023-05-16 05:38:40 -07:00