Code Activity Logger is a Python-based automation tool designed to track, summarize, and log code changes across projects. It leverages Google Gemini AI to generate intelligent summaries of modifications and maintains a structured changelog. The tool enables seamless backup of project files and automatically commits updates to a Git repository for version control. It runs automatically at midnight to detect and log changes without manual intervention.
- Automated Code Change Detection: Compares current and previous project versions to identify modifications.
- AI-Powered Summaries: Uses Google Gemini API to generate concise summaries of code changes.
- Version Control Integration: Updates and pushes the changelog to a Git repository.
- Backup System: Creates daily backups of specified project directories.
- Automatic Execution: The script runs automatically at midnight every day to check for code changes and update the changelog.
git clone https://github.com/naitik2314/Code-Activity-Logger.git
cd Code-Activity-Logger
Option 1: Using Python venv
python3 -m venv env
source env/bin/activate # On Windows, use `env\Scripts\activate`
Option 2: Using Conda
conda create --name code_logger_env python=3.9
conda activate code_logger_env
pip install -r requirements.txt
Create a .env
file in the root directory and add your Google Gemini API key:
GEMINI_API_KEY="your_api_key_here" # Refer the .env.example file for example, and make sure to change it's name to .env
Update main.py
to specify the directories being tracked and where backups should be stored:
PROJECT_DIRECTORIES = ['/path/to/your/project']
BACKUP_LOCATION = '/path/to/your/backup/directory'
git init
git remote add origin https://github.com/yourusername/yourrepository.git
- Create a new repository on GitHub named
changelog or whatever suits you
. - Clone the repository to your local system:
git clone https://github.com/yourusername/changelog.git cd changelog
- Create an empty
changelog.md
file:touch changelog.md git add changelog.md git commit -m "Initial commit with changelog.md" git push origin main
- Go to GitHub Settings > Developer settings > Personal access tokens.
- Click on "Generate new token".
- Select the scopes you need (e.g.,
repo
for full control of private repositories). - Generate the token and copy it.
- Add the token to your
.env
file:GITHUB_PAT=your_personal_access_token_here
To run the tool, simply execute:
python main.py
To run the unit tests:
python -m unittest test_script.py
/Code-Activity-Logger
│── main.py # Main script for logging and summarizing changes
│── test_script.py # Unit tests for validation
│── requirements.txt # Dependencies
│── .env # Environment variables (not included in repo)
│── README.md # Project documentation
│── changelog.md # Maintains a log of detected changes
- Python 3.9 or higher (Required for Google Gemini)
- google-generativeai (Google Gemini API)
- python-dotenv (Environment variable management)
To install manually:
pip install google-generativeai python-dotenv
All changes are logged in changelog.md
, which is automatically updated and pushed to GitHub when changes are detected.
This project is open-source and available under the MIT License.
Contributions are welcome! Please submit a pull request with detailed explanations of your changes.
- Your Name
- LinkedIn: Naitik Shah
- GitHub: naitik2314
- Convert this to a VSCode extension
- Support for local llms using llama.cpp python wrapper