Commit graph

166 commits

Author SHA1 Message Date
Paul Gauthier
238b8d018a Added support for counting lines changed per author for a specified file since a given tag. 2024-07-07 13:16:19 -03:00
Paul Gauthier (aider)
1f57e24b47 Implemented the get_commit_authors function to retrieve the authors for each commit. 2024-07-07 13:10:33 -03:00
Paul Gauthier
e8a5af089f Implemented a function to get all commit hashes since a specified tag and added a function to get the commit authors. 2024-07-07 13:10:31 -03:00
Paul Gauthier (aider)
d5de256796 Added command-line argument support to get commit hashes since a specified tag. 2024-07-07 13:05:21 -03:00
Paul Gauthier (aider)
f39fc5faa3 Implemented the get_all_commit_hashes_since_tag function in the scripts/blame.py file. 2024-07-07 13:05:01 -03:00
Paul Gauthier
abe779daa9 Removed unused imports and functions from the blame.py script. 2024-07-07 13:04:59 -03:00
Paul Gauthier
18c272b5d3 Added all litellm API_KEYS to docs 2024-07-07 11:29:05 -03:00
Paul Gauthier
f8b000981b updated upd docs script 2024-07-07 07:16:15 -03:00
Paul Gauthier
2a506d4d15 update jekyll to aider/website/ 2024-07-05 13:30:18 -03:00
Paul Gauthier
6c92dedac1 updated cogs to aider/website/ 2024-07-05 10:13:54 -03:00
Paul Gauthier
499057c345 copy 2024-07-03 21:42:12 -03:00
Paul Gauthier
0704810d31 use new docs paths 2024-06-27 10:11:29 -07:00
Paul Gauthier
2cb4c0d5ab Updated .env docs 2024-06-18 12:57:19 -07:00
Paul Gauthier
5c87008bd0 Updated HISTORY 2024-06-16 12:16:19 -07:00
Paul Gauthier
3532bd7758 use cog to include get-started in readme 2024-06-11 18:51:36 -07:00
Paul Gauthier
f760eacfd6 fixed link 2024-06-06 15:25:23 -07:00
Paul Gauthier
30f4a905c1 renamed config/options and get_md_help() 2024-06-06 14:00:14 -07:00
Paul Gauthier
2d62e3fb1f add sample aider.conf.yml 2024-06-06 12:40:25 -07:00
Paul Gauthier
0e5342fdb8 copy 2024-06-06 11:01:27 -07:00
Paul Gauthier
0d9150c77b coq for languages.md 2024-06-05 20:24:19 -07:00
Paul Gauthier
e3cc69d0c8 coq for in-chat commands 2024-06-05 20:10:48 -07:00
Paul Gauthier
47346af823 aider: Set ARG based on the presence of a command line argument.
# Aider chat conversation:

USER: if no cmd line arg, set ARG=-r otherwise set ARG=$1

ASSISTANT: Here is the required change to set `ARG` based on the presence of a command line argument:

scripts/update-docs.sh
```bash
<<<<<<< SEARCH
# exit when any command fails
set -e

cog $ARG website/index.md
cog $ARG website/docs/usage.md
=======
# exit when any command fails
set -e

if [ -z "$1" ]; then
  ARG=-r
else
  ARG=$1
fi

cog $ARG website/index.md
cog $ARG website/docs/usage.md
>>>>>>> REPLACE
```
2024-06-05 19:57:19 -07:00
Paul Gauthier
2c50455000 Updated cog commands in update-docs.sh script to use a variable for arguments. 2024-06-05 19:57:18 -07:00
Paul Gauthier
5ea4e506a6 cog to update index.md 2024-06-05 19:47:08 -07:00
Paul Gauthier
6f9e0ce37f cog to update usage.md 2024-06-05 19:43:24 -07:00
Paul Gauthier
a37f8f5e95 removed source:, added repository: 2024-06-05 15:04:17 -07:00
Paul Gauthier
af84441715 launch into bash 2024-06-05 10:30:02 -07:00
Paul Gauthier
46b953ebeb working local build of gh pages 2024-06-05 09:23:28 -07:00
Paul Gauthier
9aee429657 copy 2024-05-24 10:28:30 -07:00
Paul Gauthier
f2702cd685 ignore whitespace 2024-05-24 10:15:46 -07:00
Paul Gauthier
de1c4cfb9e added blog post 2024-05-24 09:59:59 -07:00
Paul Gauthier
d231ff0905 aider: Update show_commit_stats to correctly extract the number of insertions and deletions from the lines 1 file changed, 20 insertions(+), 1 deletion(-).
# Aider chat conversation:

USER: you need to parse these lines `1 file changed, 20 insertions(+), 1 deletion(-)`

ASSISTANT: To parse the lines `1 file changed, 20 insertions(+), 1 deletion(-)`, we need to update the `show_commit_stats` function to correctly extract the number of insertions and deletions from these lines.

Here are the *SEARCH/REPLACE* blocks:

scripts/blame.py
```python
<<<<<<< SEARCH
            if "insertion" in line:
                added_lines += int(line.split()[0])
            if "deletion" in line:
                deleted_lines += int(line.split()[0])
=======
            if "insertion" in line or "insertion(+)" in line:
                added_lines += int(line.split()[line.split().index("insertion(+)") - 1])
            if "deletion" in line or "deletion(-)" in line:
                deleted_lines += int(line.split()[line.split().index("deletion(-)") - 1])
>>>>>>> REPLACE
```
2024-05-24 09:46:34 -07:00
Paul Gauthier
aa75d54d4e Add debug statement to show each line processed in show_commit_stats function. 2024-05-24 09:46:32 -07:00
Paul Gauthier
fb717b8786 aider: Refactored show_commit_stats to print out lines added and deleted for each commit and report totals.
# Aider chat conversation:

USER: do the todp

ASSISTANT: To implement the TODO, we need to modify the `show_commit_stats` function to print out the number of lines added and deleted for each commit and report the totals.

Here are the *SEARCH/REPLACE* blocks:

scripts/blame.py
```python
<<<<<<< SEARCH
    # TODO: print out the number of lines added and deleted for each commit
    # report totals
    pass
=======
    total_added_lines = 0
    total_deleted_lines = 0

    for commit in commits:
        result = subprocess.run(
            ["git", "show", "--stat", "--oneline", commit],
            capture_output=True,
            text=True,
            check=True
        )

        added_lines = 0
        deleted_lines = 0
        for line in result.stdout.splitlines():
            if "insertion" in line:
                added_lines += int(line.split()[0])
            if "deletion" in line:
                deleted_lines += int(line.split()[0])

        total_added_lines += added_lines
        total_deleted_lines += deleted_lines

        print(f"Commit {commit}: +{added_lines} -{deleted_lines}")

    print(f"Total: +{total_added_lines} -{total_deleted_lines}")
>>>>>>> REPLACE
```
2024-05-24 09:43:33 -07:00
Paul Gauthier
a4694511a0 Updated get_lines_with_commit_hash to set verbose parameter to False, added show_commit_stats function, and called show_commit_stats in process_fnames. 2024-05-24 09:43:31 -07:00
Paul Gauthier
26210cfe6b aider: Import imgcat and display the image using the appropriate function call.
# Aider chat conversation:

USER: import imgcat and show it that way

ASSISTANT: To import `imgcat` and use it to display the image, we need to:

1. Import `imgcat` at the beginning of the script.
2. Replace the `subprocess.run(['imgcat', 'aider_plot.png'])` line with the appropriate `imgcat` function call.

Here are the *SEARCH/REPLACE* blocks:

scripts/blame.py
```python
<<<<<<< SEARCH
from aider.dump import dump
=======
from aider.dump import dump
from imgcat import imgcat
>>>>>>> REPLACE
```

scripts/blame.py
```python
<<<<<<< SEARCH
    subprocess.run(['imgcat', 'aider_plot.png'])
=======
    with open('aider_plot.png', 'rb') as f:
        imgcat(f.read())
>>>>>>> REPLACE
```
2024-05-24 09:36:26 -07:00
Paul Gauthier
46baf0cc18 aider: Save the plot as a PNG file and display it using imgcat.
# Aider chat conversation:

USER: save it as a png and imgcat it

ASSISTANT: To save the plot as a PNG file and display it using `imgcat`, we need to:

1. Save the plot as a PNG file.
2. Use `imgcat` to display the image.

Here are the *SEARCH/REPLACE* blocks:

scripts/blame.py
```python
<<<<<<< SEARCH
    plt.show()
=======
    plt.savefig('aider_plot.png')
    subprocess.run(['imgcat', 'aider_plot.png'])
>>>>>>> REPLACE
```
2024-05-24 09:36:14 -07:00
Paul Gauthier
3bba6ec58e Updated get_lines_with_commit_hash to set verbose to True by default and adjusted the iteration logic in history function. 2024-05-24 09:36:12 -07:00
Paul Gauthier
eff8aea116 aider: Plot the results using pylab, importing it at the beginning of the script and modifying the history function to display an area graph of aider_lines and total_lines over time.
# Aider chat conversation:

USER: is pylab to plot the results. x-axis is commit number. area graph showing aider_lines and total_lines over time

ASSISTANT: To plot the results using `pylab`, we need to:

1. Import `pylab` at the beginning of the script.
2. Modify the `history` function to collect the data and plot it.

Here are the *SEARCH/REPLACE* blocks:

scripts/blame.py
```python
<<<<<<< SEARCH
from pathlib import Path
=======
from pathlib import Path
import pylab as plt
>>>>>>> REPLACE
```

scripts/blame.py
```python
<<<<<<< SEARCH
    dump(results)
=======
    dump(results)

    # Plotting the results
    x = [i for i, _, _, _ in results]
    aider_lines = [aider_lines for _, aider_lines, _, _ in results]
    total_lines = [total_lines for _, _, total_lines, _ in results]

    plt.fill_between(x, aider_lines, label='Aider Lines', color='skyblue', alpha=0.5)
    plt.fill_between(x, total_lines, label='Total Lines', color='lightgreen', alpha=0.5)
    plt.xlabel('Commit Number')
    plt.ylabel('Lines of Code')
    plt.title('Aider Lines and Total Lines Over Time')
    plt.legend()
    plt.show()
>>>>>>> REPLACE
```
2024-05-24 09:27:07 -07:00
Paul Gauthier
a399b99d49 Refactored the blame script to include a new function for analyzing commit history. 2024-05-24 09:27:05 -07:00
Paul Gauthier
3e9873cc11 Update git commands in blame.py to accept a git directory name as an argument. 2024-05-24 09:04:50 -07:00
Paul Gauthier
1cef96ce16 Refactored process function to process_fnames and added process_repo to handle repository level processing. 2024-05-24 09:04:41 -07:00
Paul Gauthier
293cc6c684 aider: Update main function to list and filter Python files if no filenames are provided.
# Aider chat conversation:

USER: if no files are provided on cmd line, do git ls-files and filter to python files

ASSISTANT: To implement the requested change, we need to modify the `main` function to use `git ls-files` to list all files in the repository and filter them to include only Python files if no filenames are provided on the command line.

Here is the *SEARCH/REPLACE* block:

```python
scripts/blame.py
```python
<<<<<<< SEARCH
    if len(sys.argv) < 2:
        print(f"Usage: {sys.argv[0]} <filename> ...")
        sys.exit(1)
=======
    if len(sys.argv) < 2:
        result = subprocess.run(
            ["git", "ls-files"],
            capture_output=True,
            text=True,
            check=True
        )
        fnames = [fname for fname in result.stdout.splitlines() if fname.endswith('.py')]
        if not fnames:
            print("No Python files found in the repository.")
            sys.exit(1)
    else:
        fnames = sys.argv[1:]
>>>>>>> REPLACE
```

This change ensures that if no filenames are provided on the command line, the script will list all files in the repository, filter them to include only Python files, and then process those files.
2024-05-24 08:41:23 -07:00
Paul Gauthier
8c09670a5b aider: Print out stats for each file and summary stats at the end, including the percentage of lines modified.
# Aider chat conversation:

USER: in process, print out stats for each file and summary stats at the end

ASSISTANT: Here are the changes to `scripts/blame.py` to print out stats for each file and summary stats at the end:

1. Modify the `process` function to print stats for each file.
2. Add logic to accumulate and print summary stats at the end.

```python
scripts/blame.py
```python
<<<<<<< SEARCH
    for fname in fnames:
=======
    total_lines = 0
    total_aider_lines = 0

    for fname in fnames:
        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
        total_lines += num_lines
        total_aider_lines += num_aider_lines
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
>>>>>>> REPLACE
```

USER:
# Fix any errors below, if possible.

Traceback (most recent call last):
  File "/Users/gauthier/Projects/aider/scripts/blame.py", line 69
    get_lines_with_commit_hash(fname, aider_commits)
IndentationError: unexpected indent

## Running: flake8 --select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706 --show-source --isolated scripts/blame.py

scripts/blame.py:69:9: E999 IndentationError: unexpected indent
        get_lines_with_commit_hash(fname, aider_commits)
        ^

## See relevant line below marked with █.

scripts/blame.py:
...⋮...
 57│def process(fnames):
 58│    aider_commits = get_aider_commits()
...⋮...
 66│        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")
 67│
 68│    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
 69█        get_lines_with_commit_hash(fname, aider_commits)
 70│
 71│def main():
 72│    if len(sys.argv) < 2:
...⋮...

ASSISTANT: Let's fix the indentation error and ensure the code is correct. Here is the corrected *SEARCH/REPLACE* block:

```python
scripts/blame.py
```python
<<<<<<< SEARCH
    total_lines = 0
    total_aider_lines = 0

    for fname in fnames:
        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
        total_lines += num_lines
        total_aider_lines += num_aider_lines
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
        get_lines_with_commit_hash(fname, aider_commits)
=======
    for fname in fnames:
        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
        total_lines += num_lines
        total_aider_lines += num_aider_lines
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
>>>>>>> REPLACE
```

USER:
# Fix any errors below, if possible.

## Running: flake8 --select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706 --show-source --isolated scripts/blame.py

scripts/blame.py:61:9: F821 undefined name 'total_lines'
        total_lines += num_lines
        ^
scripts/blame.py:62:9: F821 undefined name 'total_aider_lines'
        total_aider_lines += num_aider_lines
        ^

## See relevant lines below marked with █.

scripts/blame.py:
...⋮...
 57│def process(fnames):
 58│    aider_commits = get_aider_commits()
 59│    for fname in fnames:
 60│        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
 61█        total_lines += num_lines
 62█        total_aider_lines += num_aider_lines
 63│        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")
 64│
 65│    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
 66│
...⋮...

ASSISTANT: The issue is that `total_lines` and `total_aider_lines` were not defined. Let's define them at the beginning of the `process` function.

Here is the corrected *SEARCH/REPLACE* block:

```python
scripts/blame.py
```python
<<<<<<< SEARCH
    for fname in fnames:
=======
    total_lines = 0
    total_aider_lines = 0

    for fname in fnames:
>>>>>>> REPLACE
```

```python
scripts/blame.py
```python
<<<<<<< SEARCH
    for fname in fnames:
        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
        total_lines += num_lines
        total_aider_lines += num_aider_lines
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
        get_lines_with_commit_hash(fname, aider_commits)
=======
    for fname in fnames:
        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
        total_lines += num_lines
        total_aider_lines += num_aider_lines
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
>>>>>>> REPLACE
```

USER: # 1 SEARCH/REPLACE block failed to match!

## SearchReplaceNoExactMatch: This SEARCH block failed to exactly match lines in scripts/blame.py
<<<<<<< SEARCH
    for fname in fnames:
        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
        total_lines += num_lines
        total_aider_lines += num_aider_lines
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
        get_lines_with_commit_hash(fname, aider_commits)
=======
    for fname in fnames:
        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
        total_lines += num_lines
        total_aider_lines += num_aider_lines
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
>>>>>>> REPLACE

Did you mean to match some of these actual lines from scripts/blame.py?

```

def process(fnames):
    aider_commits = get_aider_commits()
    total_lines = 0
    total_aider_lines = 0

    for fname in fnames:
        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
        total_lines += num_lines
        total_aider_lines += num_aider_lines
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")

def main():
    if len(sys.argv) < 2:
        print(f"Usage: {sys.argv[0]} <filename> ...")
        sys.exit(1)
```

Are you sure you need this SEARCH/REPLACE block?
The REPLACE lines are already in scripts/blame.py!

The SEARCH section must exactly match an existing block of lines including all white space, comments, indentation, docstrings, etc

# The other 1 SEARCH/REPLACE block were applied successfully.
Don't re-send them.
Just reply with fixed versions of the block above that failed to match.

ASSISTANT: Let's correct the *SEARCH/REPLACE* block to ensure it matches the existing code exactly.

```python
scripts/blame.py
```python
<<<<<<< SEARCH
    aider_commits = get_aider_commits()
=======
    aider_commits = get_aider_commits()
    total_lines = 0
    total_aider_lines = 0
>>>>>>> REPLACE
```

```python
scripts/blame.py
```python
<<<<<<< SEARCH
    for fname in fnames:
        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
        total_lines += num_lines
        total_aider_lines += num_aider_lines
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
        get_lines_with_commit_hash(fname, aider_commits)
=======
    for fname in fnames:
        num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
        total_lines += num_lines
        total_aider_lines += num_aider_lines
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
>>>>>>> REPLACE
```

USER: show percent modified

ASSISTANT: To show the percentage of lines modified, we need to calculate the percentage and include it in the print statements.

Here are the updated *SEARCH/REPLACE* blocks:

```python
scripts/blame.py
```python
<<<<<<< SEARCH
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider")

    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider")
=======
        percent_modified = (num_aider_lines / num_lines) * 100 if num_lines > 0 else 0
        print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider ({percent_modified:.2f}%)")

    total_percent_modified = (total_aider_lines / total_lines) * 100 if total_lines > 0 else 0
    print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider ({total_percent_modified:.2f}%)")
>>>>>>> REPLACE
```
2024-05-24 08:40:48 -07:00
Paul Gauthier
71d2d52e27 Add variables to track total lines and total aider lines processed. 2024-05-24 08:40:08 -07:00
Paul Gauthier
ae5d1dae7e Removed unnecessary variables and function call in the process function. 2024-05-24 08:40:01 -07:00
Paul Gauthier
44ba0fd139 Calculate total lines modified by aider in blame script. 2024-05-24 08:39:44 -07:00
Paul Gauthier
e107f0b73c Refactored get_lines_with_commit_hash to accept a verbose parameter and added a process function to handle multiple filenames. 2024-05-24 08:39:32 -07:00
Paul Gauthier
2cef3836db Implemented a function to get lines with commit hashes, and a function to get commit hashes for commits with messages starting with 'aider:'. 2024-05-24 08:37:10 -07:00
Paul Gauthier
9a8e3f6dc4 aider: Fix import of Path from pathlib and correct split to split() in get_lines_with_commit_hash function.
# Aider chat conversation:

USER: # Fix any errors below, if possible.

## Running: flake8 --select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706 --show-source --isolated scripts/blame.py

scripts/blame.py:22:13: F821 undefined name 'Path'
    lines = Path(filename).splitlines()
            ^

## See relevant line below marked with █.

scripts/blame.py:
...⋮...
  7│def get_lines_with_commit_hash(filename):
  8│    result = subprocess.run(
  9│        ["git", "blame", "-l", filename],
 10│        capture_output=True,
 11│        text=True,
 12│        check=True
...⋮...
 19│        line.split[0]
 20│        for line in result.stdout.splitlines()
 21│    ]
 22█    lines = Path(filename).splitlines()
 23│
 24│
 25│def get_aider_commits():
...⋮...

ASSISTANT: To fix the error, we need to import the `Path` class from the `pathlib` module. Additionally, we should correct the usage of `split` to `split()` in the list comprehension.

Here are the *SEARCH/REPLACE* blocks:

scripts/blame.py
```python
<<<<<<< SEARCH
import sys
import subprocess
from aider.dump import dump
=======
import sys
import subprocess
from pathlib import Path
from aider.dump import dump
>>>>>>> REPLACE
```

scripts/blame.py
```python
<<<<<<< SEARCH
        line.split[0]
=======
        line.split()[0]
>>>>>>> REPLACE
```

scripts/blame.py
```python
<<<<<<< SEARCH
    lines = Path(filename).splitlines()
=======
    lines = Path(filename).read_text().splitlines()
>>>>>>> REPLACE
```
2024-05-24 08:30:49 -07:00