Skip to content

Comments

feat: Add stats command to allow user to compare aider usage across different revision#2883

Open
josix wants to merge 4 commits intoAider-AI:mainfrom
josix:feat/add-aider-stat-command
Open

feat: Add stats command to allow user to compare aider usage across different revision#2883
josix wants to merge 4 commits intoAider-AI:mainfrom
josix:feat/add-aider-stat-command

Conversation

@josix
Copy link

@josix josix commented Jan 16, 2025

TODO:

  • Implementation
  • E2E Test
  • Unit Test

This pull request introduces a new feature to show code change statistics between revisions and refactors existing code to support this functionality. The most important changes include adding a new command, updating argument parsing, and refactoring common functions into a new module.

New Feature: Code Change Statistics

  • Added --stats argument to show code change statistics between revisions in aider/args.py.
  • Implemented cmd_stats method to calculate and display code change statistics in aider/commands.py.
  • Added logic to handle --stats argument in aider/main.py.

Refactoring for Code Reuse

  • Moved functions hash_len, get_all_commit_hashes_between_tags, get_commit_authors, and get_counts_for_file to a new module aider/stats.py for reuse.

Codebase Simplification

  • Updated imports in aider/commands.py and scripts/blame.py to use refactored functions from aider/stats.py. [1] [2]
  • Removed redundant functions from scripts/blame.py after refactoring. [1] [2]

Example

aider --env-file ~/aider/.env --stats v0.69.0..v0.71.0
Aider v0.71.2.dev21+g620ae5cf.d20250116
Main model: claude-3-5-sonnet-20241022 with diff edit format, infinite output
Weak model: claude-3-5-haiku-20241022
Git repo: .git with 426 files
Repo-map: using 4096 tokens, auto refresh
Found 109 non-binary tracked files in the repository.

Analysis from v0.69.0 to v0.71.0:
Total lines analyzed: 6,440
Lines by aider: 1,147 (17.8%)
Lines by humans: 5,293 (82.2%)

@CLAassistant
Copy link

CLAassistant commented Jan 16, 2025

CLA assistant check
All committers have signed the CLA.

@josix josix changed the title Add stats command to allow user to compare aider usage across different revision feat: Add stats command to allow user to compare aider usage across different revision Jan 16, 2025
@MrOrz
Copy link

MrOrz commented Jan 24, 2025

@josix josix marked this pull request as ready for review February 10, 2025 08:52
@MrOrz
Copy link

MrOrz commented Mar 12, 2025

I gave this branch a few shots and it is working as expected, calculating the Aider % between two commits. 👍🏻 👍🏻 👍🏻

It would be nice if running aider --stats without specifying any commits would compare HEAD against the master or main branch.

@josix josix force-pushed the feat/add-aider-stat-command branch from 8f0d071 to 984461c Compare March 14, 2025 12:18
@josix
Copy link
Author

josix commented Mar 14, 2025

Thanks @MrOrz for pointing it out, I've added the compared revision (HEAD) as the default value and unit tests as well.

@josix josix force-pushed the feat/add-aider-stat-command branch from 89c616b to 717b95f Compare April 28, 2025 10:39
@MrOrz
Copy link

MrOrz commented May 13, 2025

Not sure if aider --stats will be merged anytime soon.
Alternatively, I have created a bash script that calculate AI percentage here: https://github.com/MrOrz/mcp-git-commit-aider?tab=readme-ov-file#calculating-ai-contribution

@josix josix force-pushed the feat/add-aider-stat-command branch from 717b95f to 98d114e Compare May 16, 2025 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants