Commit graph

2927 commits

Author SHA1 Message Date
Paul Gauthier
6791bc19c6 added test for --encoding 2023-10-20 08:04:02 -07:00
Paul Gauthier
ac9160ae54 aider: Add --encoding argument and pass it to InputOutput.
# Aider chat conversation:

USER: add --encoding and pass it to `InputOutput`

ASSISTANT: To add the `--encoding` argument and pass it to `InputOutput`, we need to modify the `aider/main.py` file.

Here are the steps:

1. Add a new argument `--encoding` to the `argparse.ArgumentParser` in the `main` function.
2. Pass the `args.encoding` to the `InputOutput` class instantiation.

Here are the changes:

```python
aider/main.py
<<<<<<< HEAD
    ##########
    other_group = parser.add_argument_group("Other Settings")
    other_group.add_argument(
        "--version",
        action="version",
        version=f"%(prog)s {__version__}",
        help="Show the version number and exit",
    )
    other_group.add_argument(
        "--apply",
        metavar="FILE",
        help="Apply the changes from the given file instead of running the chat (debug)",
    )
    other_group.add_argument(
        "--yes",
        action="store_true",
        help="Always say yes to every confirmation",
        default=None,
    )
    other_group.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
    other_group.add_argument(
        "--show-repo-map",
        action="store_true",
        help="Print the repo map and exit (debug)",
        default=False,
    )
    other_group.add_argument(
        "--message",
        "--msg",
        "-m",
        metavar="COMMAND",
        help="Specify a single message to send GPT, process reply then exit (disables chat mode)",
    )
    other_group.add_argument(
        "-c",
        "--config",
        is_config_file=True,
        metavar="CONFIG_FILE",
        help=(
            "Specify the config file (default: search for .aider.conf.yml in git root, cwd"
            " or home directory)"
        ),
    )

    args = parser.parse_args(argv)
=======
    ##########
    other_group = parser.add_argument_group("Other Settings")
    other_group.add_argument(
        "--version",
        action="version",
        version=f"%(prog)s {__version__}",
        help="Show the version number and exit",
    )
    other_group.add_argument(
        "--apply",
        metavar="FILE",
        help="Apply the changes from the given file instead of running the chat (debug)",
    )
    other_group.add_argument(
        "--yes",
        action="store_true",
        help="Always say yes to every confirmation",
        default=None,
    )
    other_group.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
    other_group.add_argument(
        "--show-repo-map",
        action="store_true",
        help="Print the repo map and exit (debug)",
        default=False,
    )
    other_group.add_argument(
        "--message",
        "--msg",
        "-m",
        metavar="COMMAND",
        help="Specify a single message to send GPT, process reply then exit (disables chat mode)",
    )
    other_group.add_argument(
        "--encoding",
        default="utf-8",
        help="Specify the encoding for input and output (default: utf-8)",
    )
    other_group.add_argument(
        "-c",
        "--config",
        is_config_file=True,
        metavar="CONFIG_FILE",
        help=(
            "Specify the config file (default: search for .aider.conf.yml in git root, cwd"
            " or home directory)"
        ),
    )

    args = parser.parse_args(argv)
>>>>>>> updated
```

```python
aider/main.py
<<<<<<< HEAD
    io = InputOutput(
        args.pretty,
        args.yes,
        args.input_history_file,
        args.chat_history_file,
        input=input,
        output=output,
        user_input_color=args.user_input_color,
        tool_output_color=args.tool_output_color,
        tool_error_color=args.tool_error_color,
        dry_run=args.dry_run,
    )
=======
    io = InputOutput(
        args.pretty,
        args.yes,
        args.input_history_file,
        args.chat_history_file,
        input=input,
        output=output,
        user_input_color=args.user_input_color,
        tool_output_color=args.tool_output_color,
        tool_error_color=args.tool_error_color,
        dry_run=args.dry_run,
        encoding=args.encoding,
    )
>>>>>>> updated
```

Please note that the `InputOutput` class should be able to handle the `encoding` argument. If it's not the case, we need to modify the `InputOutput` class as well.
2023-10-19 20:18:02 -07:00
Paul Gauthier
cd30e531be better warnings on files that are missing or not normal 2023-10-19 10:09:16 -07:00
Paul Gauthier
54742a2d75 Updated HISTORY 2023-10-19 08:01:15 -07:00
Paul Gauthier
25c06940d6 re-enable twine/pypi 2023-10-19 07:09:09 -07:00
Paul Gauthier
02386c16aa setup multi-arch docker images 2023-10-19 07:00:23 -07:00
Paul Gauthier
b2b78a98ee Added libportaudio2 to the docker container 2023-10-18 13:38:41 -07:00
Paul Gauthier
49b9034629 Added universal ctags to the docker image 2023-10-18 13:30:49 -07:00
Paul Gauthier
790f7ddee3 make the docker image a bit smaller 2023-10-18 13:26:20 -07:00
Paul Gauthier
ee3f3a44fd aider: Refactored Dockerfile to combine RUN commands, use --no-cache-dir option when installing Python packages, and remove unnecessary pip install --upgrade pip command.
# Aider chat conversation:

ASSISTANT: Yes, there are a few more things we can do to clean up the Dockerfile:

1. We can combine the `RUN` commands into a single command to reduce the number of layers in the Docker image. This can make the image smaller and faster to build.

2. We can use the `--no-cache-dir` option when installing Python packages with pip. This will prevent pip from caching downloaded packages, which can save space in the Docker image.

3. We can remove the `pip install --upgrade pip` command. The Python Docker images are regularly updated, so the version of pip included in the image is usually fairly recent.

Here's how we can make these changes:

```dockerfile
docker/Dockerfile
<<<<<<< HEAD
FROM python:3.10-slim
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
COPY . /aider
RUN pip install --upgrade pip && pip install /aider && rm -rf /aider
WORKDIR /app
ENTRYPOINT ["aider"]
=======
FROM python:3.10-slim
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* && \
    pip install --no-cache-dir /aider && rm -rf /aider
WORKDIR /app
ENTRYPOINT ["aider"]
>>>>>>> updated
```

Please note that these changes will make the Docker image smaller and faster to build, but they won't affect the functionality of the application.
2023-10-18 13:19:22 -07:00
Paul Gauthier
a6a49b13bb Remove the /aider directory after installing the package. 2023-10-18 13:19:21 -07:00
Paul Gauthier
8561bfde33 copy 2023-10-18 13:13:42 -07:00
Paul Gauthier
a4cd4ac65f Updated HISTORY 2023-10-18 13:09:59 -07:00
Paul Gauthier
88e42a124b copy 2023-10-18 12:47:26 -07:00
Paul Gauthier
dffeaac4d9 Added --commit command #283 2023-10-18 12:45:51 -07:00
Paul Gauthier
3f2dfa24ee aider: Add a --commit arg that commits all pending changes with a suitable commit message.
# Aider chat conversation:

USER: Add a --commit arg that will commit all pending changes with a suitable commit message

ASSISTANT: To add a `--commit` argument, we need to modify the `aider/main.py` file. Specifically, we will add a new argument to the `git_group` argument group in the `main` function.

Here is the proposed change:

```python
aider/main.py
<<<<<<< HEAD
    git_group.add_argument(
        "--dry-run",
        action=argparse.BooleanOptionalAction,
        default=False,
        help="Enable/disable performing a dry run without modifying files (default: False)",
    )
=======
    git_group.add_argument(
        "--dry-run",
        action=argparse.BooleanOptionalAction,
        default=False,
        help="Enable/disable performing a dry run without modifying files (default: False)",
    )
    git_group.add_argument(
        "--commit",
        action="store_true",
        help="Commit all pending changes with a suitable commit message",
        default=False,
    )
>>>>>>> updated
```

This change adds a new `--commit` argument that, when used, will trigger the commit of all pending changes. The default value is `False`, meaning that if the argument is not provided, no commit will be made. The help text provides a brief explanation of what the argument does.

After adding this argument, you will need to implement the functionality to commit changes when this argument is used. This will likely involve modifying the `GitRepo` class in the `aider/repo.py` file, but since that file is read-only, I can't provide the specific changes here.
2023-10-18 12:44:11 -07:00
Paul Gauthier
5756812938 Adopt subprocess.run(shell=True) for /git 2023-10-18 12:37:39 -07:00
paul-gauthier
44aa5c6d63
Merge pull request #272 from alexanderkjeldaas/ak/run-shell
fix: /run (cd ..; ls) should work
2023-10-18 12:35:17 -07:00
Paul Gauthier
1085549548 Give up testing aiderignore caching in github actions 2023-10-18 12:28:24 -07:00
Paul Gauthier
df27007c00 wtf 2023-10-18 12:22:01 -07:00
Paul Gauthier
1a2370f9ae sleep in the test 2023-10-18 12:15:11 -07:00
Paul Gauthier
b87c9f14fb put back caching, add debug output 2023-10-18 12:11:07 -07:00
Paul Gauthier
d1cd0f9860 do not cache aiderignore 2023-10-18 12:06:47 -07:00
Paul Gauthier
cf00037442 st_mtime_ns? 2023-10-18 12:04:09 -07:00
Paul Gauthier
a1cb6e4e7a More paranoid mtime check 2023-10-18 11:55:04 -07:00
Paul Gauthier
5e50307748 Added pathspec to reqs 2023-10-18 11:39:01 -07:00
Paul Gauthier
82dc995a04 Added helpful suggestions to /undo and /diff errors 2023-10-18 11:38:54 -07:00
Paul Gauthier
2e6c785c3b cache aiderignore 2023-10-18 10:39:07 -07:00
Paul Gauthier
583c3285ec added tests, fixed bug 2023-10-18 10:31:45 -07:00
Paul Gauthier
9725b236a3 roughed in .aiderignore 2023-10-18 10:26:43 -07:00
Paul Gauthier
f8e30ad7a0 aider: Added import for pathspec library and implemented filter_ignored_files method to filter filenames according to gitignore type specifications in self.aider_ignore_file.
# Aider chat conversation:

ASSISTANT: To implement the `filter_ignored_files` method, we need to use the `pathspec` library to filter the filenames according to the gitignore type specifications in `self.aider_ignore_file`.

The `pathspec` library is not currently imported in the `repo.py` file, so we need to add that import.

We also need to read the `aider_ignore_file` and use its contents to create a `pathspec` that we can use to filter the filenames.

Here are the changes:

```python
aider/repo.py
<<<<<<< HEAD
import os
from pathlib import Path, PurePosixPath

import git

from aider import models, prompts, utils
from aider.sendchat import simple_send_with_retries

from .dump import dump  # noqa: F401
=======
import os
import pathspec
from pathlib import Path, PurePosixPath

import git

from aider import models, prompts, utils
from aider.sendchat import simple_send_with_retries

from .dump import dump  # noqa: F401
>>>>>>> updated
```

```python
aider/repo.py
<<<<<<< HEAD
    def filter_ignored_files(self, fnames):
        if not self.aider_ignore_file:
            return

        # todo: use pathspec to filter fnames according to the gitignore type specs in self.aider_ignore_file
=======
    def filter_ignored_files(self, fnames):
        if not self.aider_ignore_file:
            return fnames

        with open(self.aider_ignore_file, 'r') as f:
            ignore_spec = pathspec.PathSpec.from_lines('gitwildmatch', f)

        return [fname for fname in fnames if not ignore_spec.match_file(fname)]
>>>>>>> updated
```

Please note that these changes assume that `self.aider_ignore_file` is a path to a file containing gitignore-style patterns, one per line. If `self.aider_ignore_file` is not in this format, the code may need to be adjusted.
2023-10-18 10:24:54 -07:00
Paul Gauthier
10f2e114c5 Added a new parameter aider_ignore_file to the __init__ method of GitRepo class and added a new method filter_ignored_files to filter files based on gitignore type specs. 2023-10-18 10:24:52 -07:00
Paul Gauthier
6f453e2ac1 aider: Add a switch for an aider ignore file, which defaults to .aiderignore in the root of the git repo.
# Aider chat conversation:

USER: add a switch for an aider ignore file, which should default to .aiderignore in the root of the git repo

ASSISTANT: To add a switch for an aider ignore file, we need to modify the `aider/main.py` file. We will add a new argument to the `argparse.ArgumentParser` instance to accept the path of the aider ignore file. The default value will be `.aiderignore` in the root of the git repo.

Here is the *edit block* for the change:

```python
aider/main.py
<<<<<<< HEAD
    ##########
    git_group = parser.add_argument_group("Git Settings")
    git_group.add_argument(
        "--git",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable looking for a git repo (default: True)",
    )
    git_group.add_argument(
        "--gitignore",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable adding .aider* to .gitignore (default: True)",
    )
    git_group.add_argument(
        "--auto-commits",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable auto commit of GPT changes (default: True)",
    )
    git_group.add_argument(
        "--dirty-commits",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable commits when repo is found dirty (default: True)",
    )
    git_group.add_argument(
        "--dry-run",
        action=argparse.BooleanOptionalAction,
        default=False,
        help="Enable/disable performing a dry run without modifying files (default: False)",
    )
=======
    ##########
    git_group = parser.add_argument_group("Git Settings")
    git_group.add_argument(
        "--git",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable looking for a git repo (default: True)",
    )
    git_group.add_argument(
        "--gitignore",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable adding .aider* to .gitignore (default: True)",
    )
    git_group.add_argument(
        "--aiderignore",
        metavar="AIDERIGNORE",
        default=".aiderignore",
        help="Specify the aider ignore file (default: .aiderignore in git root)",
    )
    git_group.add_argument(
        "--auto-commits",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable auto commit of GPT changes (default: True)",
    )
    git_group.add_argument(
        "--dirty-commits",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable commits when repo is found dirty (default: True)",
    )
    git_group.add_argument(
        "--dry-run",
        action=argparse.BooleanOptionalAction,
        default=False,
        help="Enable/disable performing a dry run without modifying files (default: False)",
    )
>>>>>>> updated
```

This change adds a new command-line argument `--aiderignore` that allows the user to specify the path of the aider ignore file. The default value is `.aiderignore`, which will be located in the root of the git repo.
2023-10-18 10:17:44 -07:00
Paul Gauthier
bf154b548e Only warn once about non-files being excluded from the repo map #281 2023-10-18 10:15:07 -07:00
Paul Gauthier
4f9d778d09 set version to 0.14.3-dev 2023-10-18 09:36:29 -07:00
Paul Gauthier
fcaaeef5c0 version bump to 0.14.2 2023-10-18 09:36:01 -07:00
Paul Gauthier
360e008964 make versionbump executable 2023-10-18 09:35:32 -07:00
Paul Gauthier
5b494a114e copy 2023-10-18 09:33:01 -07:00
Paul Gauthier
4a10087a6e Moved docker docs into docs/ 2023-10-18 09:31:17 -07:00
Paul Gauthier
84b05a5678 Updated HISTORY 2023-10-18 09:29:54 -07:00
Paul Gauthier
531c640705 Suggest updated git user locally, not globally 2023-10-18 09:27:12 -07:00
Paul Gauthier
be201657b8 copy 2023-10-18 09:20:36 -07:00
Paul Gauthier
55d33efbfb copy 2023-10-18 09:18:43 -07:00
Paul Gauthier
fc92862017 enable pypi again 2023-10-18 09:15:40 -07:00
Paul Gauthier
44afdeff25 aider: Updated build and push action to include the ":latest" tag when pushing the Docker image.
# Aider chat conversation:

USER: i also want to update :latest when i push

ASSISTANT: To update the `:latest` tag each time you push, you can add it to the `tags` parameter of the `docker/build-push-action` action in your workflow file. This will build and push the Docker image with both the branch or tag name and `latest` as tags.

Here's how you can update your workflow file:

```yaml
.github/workflows/release.yml
<<<<<<< HEAD
    - name: Build and push Docker image
      uses: docker/build-push-action@v5
      with:
        context: .
        file: ./docker/Dockerfile
        push: true
        tags: ${{ secrets.DOCKERHUB_USERNAME }}/aider:${{ github.ref_name }}
=======
    - name: Build and push Docker image
      uses: docker/build-push-action@v5
      with:
        context: .
        file: ./docker/Dockerfile
        push: true
        tags: |
          ${{ secrets.DOCKERHUB_USERNAME }}/aider:${{ github.ref_name }}
          ${{ secrets.DOCKERHUB_USERNAME }}/aider:latest
>>>>>>> updated
```

This will ensure that the `:latest` tag always points to the most recently pushed image.
2023-10-18 09:05:53 -07:00
Paul Gauthier
87296ddcee aider: Updated Docker tag to use github.ref_name instead of github.ref.
# Aider chat conversation:

USER: how can i test this release action?

ASSISTANT: Testing a GitHub Actions workflow can be done in a few ways:

1. **Push to a branch:** You can push your changes to a branch and see if the workflow runs as expected. This is the most straightforward way to test a workflow, but it may not be suitable if the workflow is supposed to run on specific events like a release or a tag.

2. **Use Pull Requests:** If your workflow should run on pull requests, you can open a pull request to trigger the workflow.

3. **Use Actions tab on GitHub:** You can manually trigger a workflow run from the Actions tab in your GitHub repository. Click on the workflow you want to run, then click `Run workflow` and select the branch you want to run the workflow on.

4. **Use a workflow_dispatch event:** You can add a `workflow_dispatch` event to your workflow file to manually trigger the workflow from GitHub's UI. Here's an example of how to add it:

```yaml
on:
  workflow_dispatch:
  push:
    tags:
      - 'v*'
```

After adding this to your workflow file and pushing it to your repository, you can manually trigger the workflow from the Actions tab in your GitHub repository.

5. **Use a specific branch for testing:** If your workflow runs on a push to a specific branch, you can create a separate branch for testing. You can push your changes to this branch to test the workflow.

6. **Use act:** [act](https://github.com/nektos/act) is a tool that lets you run your GitHub Actions workflows locally. This can be useful for testing your workflows before pushing them to your repository.

Remember to remove or comment out any actions that could have side effects (like publishing a package or pushing a Docker image) when you're testing your workflows.

USER: what will github.ref be if i manually trigger?

ASSISTANT: When you manually trigger a workflow using the `workflow_dispatch` event, the `github.ref` will be set to the branch or tag you selected when you triggered the workflow.

If you didn't select a branch or tag (which is possible if your workflow file doesn't specify any `inputs` for the `workflow_dispatch` event), `github.ref` will be set to the default branch of your repository (usually `main` or `master`).

Here's an example of how you can specify an input for the `workflow_dispatch` event:

```yaml
on:
  workflow_dispatch:
    inputs:
      branch:
        description: 'Branch or tag to run the workflow on'
        required: true
        default: 'main'
```

In this example, when you manually trigger the workflow, you'll be prompted to enter a branch or tag. The value you enter will be available in the `github.event.inputs.branch` context, and `github.ref` will be set to the same value.

USER: buildx failed with: ERROR: invalid tag "***/aider:refs/tags/v0.14.2-dev1": invalid reference format

ASSISTANT: The error message indicates that the Docker tag is not valid. Docker tags cannot contain slashes (`/`), and `github.ref` includes the full Git reference, which will be something like `refs/tags/v0.14.2-dev1` for a tag.

To fix this, you can use the `github.ref_name` context instead of `github.ref`. The `github.ref_name` context contains just the name of the branch or tag without the `refs/heads/` or `refs/tags/` prefix.

Here's how you can update your workflow file:

```yaml
.github/workflows/release.yml
<<<<<<< HEAD
    - name: Build and push Docker image
      uses: docker/build-push-action@v5
      with:
        context: .
        file: ./docker/Dockerfile
        push: true
        tags: ${{ secrets.DOCKERHUB_USERNAME }}/aider:${{ github.ref }}
=======
    - name: Build and push Docker image
      uses: docker/build-push-action@v5
      with:
        context: .
        file: ./docker/Dockerfile
        push: true
        tags: ${{ secrets.DOCKERHUB_USERNAME }}/aider:${{ github.ref_name }}
>>>>>>> updated
```

This will tag the Docker image with just the name of the branch or tag that triggered the workflow run, which should be a valid Docker tag.
2023-10-18 09:01:37 -07:00
Paul Gauthier
8cb9d1d64d update actions 2023-10-18 08:54:26 -07:00
Paul Gauthier
ec13c87e8d disable pypi for now 2023-10-18 08:48:24 -07:00
Paul Gauthier
b69edcfcba prep docker build to run in github action 2023-10-18 08:45:02 -07:00
Paul Gauthier
5769821a35 aider: Updated Dockerfile path to ./docker/Dockerfile in the docker/build-push-action action.
# Aider chat conversation:

USER: what is github.ref?

ASSISTANT: In GitHub Actions, `github.ref` is a context variable that refers to the branch or tag name that triggered the workflow run.

For example, if you push a commit to the `main` branch, `github.ref` will be `refs/heads/main`. If you create a tag named `v1.0.0`, `github.ref` will be `refs/tags/v1.0.0`.

In your workflow file, you're using `github.ref` to tag the Docker image. This means that the Docker image will be tagged with the name of the branch or tag that triggered the workflow run.

However, since you're triggering the workflow on tag creation (`on: push: tags: - 'v*'`), `github.ref` will always be the name of the tag. If you create a tag named `v1.0.0`, the Docker image will be tagged as `v1.0.0`.

USER: the Dockerfile is in the docker/ subdir.

ASSISTANT: If your Dockerfile is in the `docker/` subdirectory, you need to specify this in the `context` and `file` parameters of the `docker/build-push-action` action in your GitHub Actions workflow file.

The `context` parameter is the path to the directory that contains the Dockerfile. The `file` parameter is the path to the Dockerfile.

Here are the changes you need to make to the `.github/workflows/release.yml` file:

```yaml
.github/workflows/release.yml
<<<<<<< HEAD
    - name: Build and push Docker image
      uses: docker/build-push-action@v2
      with:
        context: .
        push: true
        tags: ${{ secrets.DOCKERHUB_USERNAME }}/aider:${{ github.ref }}
=======
    - name: Build and push Docker image
      uses: docker/build-push-action@v2
      with:
        context: .
        file: ./docker/Dockerfile
        push: true
        tags: ${{ secrets.DOCKERHUB_USERNAME }}/aider:${{ github.ref }}
>>>>>>> updated
```

This will tell the `docker/build-push-action` action to look for the Dockerfile in the `docker/` subdirectory.
2023-10-18 08:38:30 -07:00