Commit graph

2576 commits

Author SHA1 Message Date
Paul Gauthier
0db9d210d7 Advise the user when chat history is being summarized 2023-07-24 19:05:57 -03:00
Paul Gauthier
844194c268 Merge branch 'refactor-repo' into chat-history 2023-07-24 18:48:26 -03:00
Paul Gauthier
c8f1c0609d tests and bugfix 2023-07-24 17:47:53 -03:00
Paul Gauthier
957f59c011 updated help 2023-07-24 17:35:47 -03:00
Paul Gauthier
cac627ae5f aider: Add None as the third argument in all calls to GitRepo.
# Aider chat conversation:

USER: `GitRepo` now takes a 3rd arg. add None as the missing arg in all calls

ASSISTANT: To add `None` as the third argument in all calls to `GitRepo`, we need to modify the `tests/test_repo.py` file.

Here are the changes:

```python
tests/test_repo.py
<<<<<<< ORIGINAL
        repo = GitRepo(InputOutput(), None)
=======
        repo = GitRepo(InputOutput(), None, None)
>>>>>>> UPDATED
```

```python
tests/test_repo.py
<<<<<<< ORIGINAL
        repo = GitRepo(InputOutput(), None)
=======
        repo = GitRepo(InputOutput(), None, None)
>>>>>>> UPDATED
```

```python
tests/test_repo.py
<<<<<<< ORIGINAL
        repo = GitRepo(InputOutput(), None)
=======
        repo = GitRepo(InputOutput(), None, None)
>>>>>>> UPDATED
```

```python
tests/test_repo.py
<<<<<<< ORIGINAL
        tracked_files = GitRepo(InputOutput(), [tempdir]).get_tracked_files()
=======
        tracked_files = GitRepo(InputOutput(), [tempdir], None).get_tracked_files()
>>>>>>> UPDATED
```

```python
tests/test_repo.py
<<<<<<< ORIGINAL
            git_repo = GitRepo(InputOutput(), None)
=======
            git_repo = GitRepo(InputOutput(), None, None)
>>>>>>> UPDATED
```
2023-07-24 17:32:09 -03:00
Paul Gauthier
64c50bab48 Accept either a git dname or a list of fnames 2023-07-24 17:31:00 -03:00
Paul Gauthier
256dd7bbd9 Merge branch 'main' into refactor-repo 2023-07-24 15:22:20 -03:00
Paul Gauthier
d146398434 set version to 0.10.1-dev 2023-07-24 15:12:37 -03:00
Paul Gauthier
1f91735e88 version bump to 0.10.1 2023-07-24 15:12:18 -03:00
Paul Gauthier
ece45c7dc2 Bugfix versionbump 2023-07-24 15:12:15 -03:00
Paul Gauthier
62344a39cc Updated HISTORY 2023-07-24 15:06:58 -03:00
Paul Gauthier
d534dffe0a Updated HISTORY 2023-07-24 15:06:21 -03:00
Paul Gauthier
ccd5089e93 Merge branch 'main' into chat-history 2023-07-24 14:51:02 -03:00
Paul Gauthier
0fa4c8501d Merge branch 'main' into refactor-repo 2023-07-24 14:50:56 -03:00
Paul Gauthier
b006b39c6f GPT should ask users to add files to the chat 2023-07-24 14:49:12 -03:00
Paul Gauthier
7804925e42 Merge branch 'main' into chat-history 2023-07-24 14:24:40 -03:00
Paul Gauthier
94a271d522 Merge branch 'main' into refactor-repo 2023-07-24 14:24:20 -03:00
Paul Gauthier
17729280c6 Merge remote-tracking branch 'origin/main' 2023-07-24 14:05:45 -03:00
Paul Gauthier
745b3c320b Scan the git index using entries, which does not rely on a prior commit 2023-07-24 14:00:35 -03:00
Paul Gauthier
66da82094d use index.entries 2023-07-24 13:47:33 -03:00
Paul Gauthier
df096272bc aider: Refactored get_tracked_files method to use index.entries instead of index.diff to enumerate staged files.
# Aider chat conversation:

USER: is there any way to enumerate the staged files using the index besides index.diff

ASSISTANT: Yes, you can enumerate the staged files using the `index.entries` property of the `IndexFile` object. This property returns a dictionary-like object where the keys are the file paths and the values are `IndexEntry` objects.

Here's how you can modify the `get_tracked_files` method in the `GitRepo` class to use `index.entries` instead of `index.diff`:

```python
aider/repo.py
<<<<<<< ORIGINAL
    def get_tracked_files(self):
        if not self.repo:
            return []

        try:
            commit = self.repo.head.commit
        except ValueError:
            commit = None

        files = []
        if commit:
            for blob in commit.tree.traverse():
                if blob.type == "blob":  # blob is a file
                    files.append(blob.path)

        # Add staged files
        index = self.repo.index
        staged_files = [item.a_path for item in index.diff(None)]
        dump(staged_files)
        files.extend(staged_files)

        # convert to appropriate os.sep, since git always normalizes to /
        res = set(str(Path(PurePosixPath(path))) for path in files)

        return res
=======
    def get_tracked_files(self):
        if not self.repo:
            return []

        try:
            commit = self.repo.head.commit
        except ValueError:
            commit = None

        files = []
        if commit:
            for blob in commit.tree.traverse():
                if blob.type == "blob":  # blob is a file
                    files.append(blob.path)

        # Add staged files
        index = self.repo.index
        staged_files = [str(Path(PurePosixPath(path))) for path in index.entries.keys()]
        dump(staged_files)
        files.extend(staged_files)

        # convert to appropriate os.sep, since git always normalizes to /
        res = set(str(Path(PurePosixPath(path))) for path in files)

        return res
>>>>>>> UPDATED
```

This change will make the `get_tracked_files` method return all files in the index, not just the ones that have been modified. If you only want to get the files that have been modified, you should stick with using `index.diff`.
2023-07-24 13:45:10 -03:00
Paul Gauthier
f87ec8c38b Refactor getting staged files to handle ValueError. 2023-07-24 13:44:22 -03:00
Paul Gauthier
89542d2139 aider: Handle the case where the repository has never had any commits by using index.diff(None) to get the staged files.
# Aider chat conversation:

USER: index.diff("HEAD") fails when the repo has never had any commits

ASSISTANT: To handle the case where the repository has never had any commits, we can add a try-except block around the `index.diff("HEAD")` call in the `get_tracked_files` method of the `GitRepo` class in the `aider/repo.py` file. If a `git.exc.BadName` exception is raised, we can assume that there are no commits and return an empty list for the staged files.

Here is the proposed change:

```python
aider/repo.py
<<<<<<< ORIGINAL
        # Add staged files
        index = self.repo.index
        staged_files = [item.a_path for item in index.diff("HEAD")]
        files.extend(staged_files)
=======
        # Add staged files

^C KeyboardInterrupt

USER: there can be staged files when there are not commits

ASSISTANT: You're correct. If there are no commits, `index.diff("HEAD")` will fail, but there can still be staged files. We can use `index.diff(None)` to get the staged files in this case. Here's the proposed change:

```python
aider/repo.py
<<<<<<< ORIGINAL
        # Add staged files
        index = self.repo.index
        staged_files = [item.a_path for item in index.diff("HEAD")]
        files.extend(staged_files)
=======
        # Add staged files
        index = self.repo.index
        try:
            staged_files = [item.a_path for item in index.diff("HEAD")]
        except git.exc.BadName:
            staged_files = [item.a_path for item in index.diff(None)]
        files.extend(staged_files)
>>>>>>> UPDATED
```
2023-07-24 13:43:05 -03:00
Paul Gauthier
bef1d00ab1 Refactor test_get_tracked_files_with_new_staged_file to use a GitTemporaryDirectory and add new assertions. 2023-07-24 13:42:05 -03:00
Paul Gauthier
96f15c4533 Be sure to include staged files in get_tracked_files 2023-07-24 13:05:00 -03:00
Paul Gauthier
85166341d1 aider: Add staged files to the list of tracked files in the get_tracked_files method.
# Aider chat conversation:

USER: doing commit.tree.traverse() is not picking up files which have been git added but not yet committed

ASSISTANT: To include files that have been staged but not yet committed, you need to use the `git diff --cached` command. This command shows the changes between the index and your last commit; in other words, what you would be committing if you run "git commit" without "-a" option.

However, this change requires modification of the `aider/repo.py` file, which is currently read-only. Could you please make it read-write so that I can propose the necessary changes?

USER: I added these *read-write* files: aider/repo.py

ASSISTANT: Great, now that we have write access to `aider/repo.py`, we can modify the `get_tracked_files` method to include files that have been staged but not yet committed.

Here are the steps:

1. We will use the `git diff --cached --name-only` command to get a list of staged files. This command lists the file names that have been added (staged) but not yet committed.

2. We will add these staged files to the list of tracked files.

Here is the *edit block* for the changes:

```python
aider/repo.py
<<<<<<< ORIGINAL
    def get_tracked
^C KeyboardInterrupt

USER: is there a way to use traverse?

ASSISTANT: Yes, you can use the `git.IndexFile` object to traverse the staged files. The `IndexFile` object represents the git index, which is where files are staged before they are committed.

Here are the steps:

1. Get the `IndexFile` object from the `Repo` object.
2. Traverse the `IndexFile` object to get the staged files.

Here is the *edit block* for the changes:

```python
aider/repo.py
<<<<<<< ORIGINAL
    def get_tracked_files(self):
        if not self.repo:
            return []

        try:
            commit = self.repo.head.commit
        except ValueError:
            return set()

        files = []
        for blob in commit.tree.traverse():
            if blob.type == "blob":  # blob is a file
                files.append(blob.path)

        # convert to appropriate os.sep, since git always normalizes to /
        res = set(str(Path(PurePosixPath(path))) for path in files)

        return res
=======
    def get_tracked_files(self):
        if not self.repo:
            return []

        try:
            commit = self.repo.head.commit
        except ValueError:
            return set()

        files = []
        for blob in commit.tree.traverse():
            if blob.type == "blob":  # blob is a file
                files.append(blob.path)

        # Add staged files
        index = self.repo.index
        staged_files = [item.a_path for item in index.diff("HEAD")]
        files.extend(staged_files)

        # convert to appropriate os.sep, since git always normalizes to /
        res = set(str(Path(PurePosixPath(path))) for path in files)

        return res
>>>>>>> UPDATED
```

This change will ensure that the `get_tracked_files` method returns both committed and staged files.
2023-07-24 13:03:38 -03:00
paul-gauthier
8c6b50c64f
Update install.md 2023-07-23 16:18:30 -03:00
paul-gauthier
e63ae71e3e
Update install.md 2023-07-23 16:17:50 -03:00
Paul Gauthier
e52807b868 cleanup 2023-07-23 10:31:59 -03:00
Paul Gauthier
94c4aad2db Merge branch 'main' into chat-history 2023-07-23 10:23:45 -03:00
Paul Gauthier
143ca36733 Merge branch 'main' into refactor-repo 2023-07-23 10:23:38 -03:00
paul-gauthier
f6e5f4c539
Merge pull request #131 from joshuavial/command-docs
More complete docs for prompt commands
2023-07-23 10:23:10 -03:00
Paul Gauthier
4238986991 Updated HISTORY 2023-07-23 10:16:48 -03:00
paul-gauthier
e2466333ad
Merge pull request #141 from paul-gauthier/issue-139
/add and /drop problems when cwd != git_root #139 #95
2023-07-23 10:08:24 -03:00
Paul Gauthier
699f1598fc Ignore errors (Windows) 2023-07-23 10:04:18 -03:00
Paul Gauthier
0a5155e5bd brought over test_cmd_add_from_subdir from pr #97 2023-07-23 10:00:00 -03:00
Paul Gauthier
450a5fff19 Added test case and fix for /drop too 2023-07-23 08:41:56 -03:00
Paul Gauthier
d785d9a2e2 fix for #139 2023-07-23 08:34:56 -03:00
Paul Gauthier
9352bc67ca Added test case for issue #139 2023-07-23 08:34:19 -03:00
Paul Gauthier
47b550c62f aider: Switched open calls to use Path.write_text.
# Aider chat conversation:

USER: also swith the open calls to use Path.write_text

ASSISTANT: To switch the `open` calls to use `Path.write_text` in `test_cmd_add_drop_directory`, we need to modify the `tests/test_commands.py` file. Here are the changes:

```python
tests/test_commands.py
<<<<<<< ORIGINAL
        with open(Path("test_dir/test_file1.txt"), "w") as f:
            f.write("Test file 1")
        with open(Path("test_dir/test_file2.txt"), "w") as f:
            f.write("Test file 2")
        with open(Path("test_dir/another_dir/test_file.txt"), "w") as f:
            f.write("Test file 3")
=======
        Path("test_dir/test_file1.txt").write_text("Test file 1")
        Path("test_dir/test_file2.txt").write_text("Test file 2")
        Path("test_dir/another_dir/test_file.txt").write_text("Test file 3")
>>>>>>> UPDATED
```

This change replaces the `open` calls with `Path().write_text()` from the pathlib module.
2023-07-23 08:19:17 -03:00
Paul Gauthier
d695fe103b aider: Switched all the os calls to use pathlib in test_cmd_add_drop_directory.
# Aider chat conversation:

USER: switch all the os calls to use pathlib in `test_cmd_add_drop_directory`

ASSISTANT: To switch all the os calls to use pathlib in `test_cmd_add_drop_directory`, we need to modify the `tests/test_commands.py` file. Here are the changes:

```python
tests/test_commands.py
<<<<<<< ORIGINAL
        # Create a directory and add files to it
        os.mkdir("test_dir")
        os.mkdir("test_dir/another_dir")
        with open("test_dir/test_file1.txt", "w") as f:
            f.write("Test file 1")
        with open("test_dir/test_file2.txt", "w") as f:
            f.write("Test file 2")
        with open("test_dir/another_dir/test_file.txt", "w") as f:
            f.write("Test file 3")
=======
        # Create a directory and add files to it using pathlib
        Path("test_dir").mkdir()
        Path("test_dir/another_dir").mkdir()
        with open(Path("test_dir/test_file1.txt"), "w") as f:
            f.write("Test file 1")
        with open(Path("test_dir/test_file2.txt"), "w") as f:
            f.write("Test file 2")
        with open(Path("test_dir/another_dir/test_file.txt"), "w") as f:
            f.write("Test file 3")
>>>>>>> UPDATED
```

This change replaces the `os.mkdir` calls with `Path().mkdir()` from the pathlib module. It also changes the file paths in the `open` calls to use `Path()`.
2023-07-23 08:18:34 -03:00
Paul Gauthier
e5ffb78224 wip 2023-07-22 16:09:57 -03:00
Paul Gauthier
69aea3e745 Add summary prefix 2023-07-22 12:11:01 -03:00
Paul Gauthier
c26917851f Added a ChatSummary object to Coder class and used it to summarize chat history. 2023-07-22 10:34:48 -03:00
Paul Gauthier
0d0ac4f61f works 2023-07-22 10:32:32 -03:00
Paul Gauthier
133c82528e prompt 2023-07-22 10:02:53 -03:00
Paul Gauthier
a2ce9c4403 feed markdown into summarizer 2023-07-22 09:58:57 -03:00
Paul Gauthier
c8e8967d45 wip 2023-07-22 09:50:41 -03:00
Paul Gauthier
6e03d2f214 Merge branch 'refactor-repo' into chat-history 2023-07-22 09:48:05 -03:00
Paul Gauthier
9ab21d36a6 bugfix 2023-07-22 09:47:54 -03:00