Watch Commits for Git - Automated GitHub commit summarization with LLM
Project description
๐ WCG - Watch Commits for Git
WCG is an automated GitHub commit monitoring and summarization tool that intelligently analyzes and summarizes code changes using LLM technology.
โจ Features
- ๐ค Intelligent Summarization: Automatically generate commit summaries using LLM (OpenAI-compatible API)
- โจ Custom Prompts: Fully customizable system and user prompts to control AI behavior and output format
- ๐ Categorized Organization: Display changes categorized by additions, modifications, and deletions
- ๐ PR Association: Automatically associate Pull Requests and provide file change links
- โฐ Scheduled Execution: Automatically process commits from the last 24 hours at a scheduled time (default: 10:00 AM)
- ๐ข Webhook Notifications: Support multiple webhook formats (Generic, Slack, Discord, Feishu/Lark)
- ๐พ Local Storage: Save summaries locally organized by date
- ๐ Web Configuration Interface: Manage configuration with a user-friendly Web UI that automatically saves changes
- ๐ฆ Easy Deployment: Packaged with
uvand published to PyPI
๐ฆ Installation
Install from PyPI
pip install wcg
Install from Source
# Clone the repository
git clone https://github.com/wZuck/WCG.git
cd WCG
# Install using uv
uv pip install -e .
๐ Quick Start
1. Configuration (Option A: Manual Configuration)
Copy the example configuration file:
mkdir -p config
cp config/config.example.yaml config/config.yaml
Edit config/config.yaml and fill in your configuration:
llm:
api_url: "https://api.openai.com/v1"
api_key: "your-api-key-here"
model: "gpt-3.5-turbo"
github_token: "your-github-token-here"
repositories:
- name: "owner/repository"
branch: "main"
webhook_url: "https://your-webhook-url.com"
schedule_time: "10:00"
timezone: "Asia/Shanghai" # UTC+8 China Standard Time
summary_dir: "summaries"
Note: schedule_time uses the configured timezone (default Asia/Shanghai UTC+8). If the server time is inaccurate, set timezone to the target timezone, and the program will execute according to that timezone.
2. Configuration (Option B: Web Interface - Recommended)
Start the web configuration server:
wcg-web
Visit http://localhost:5000 in your browser to configure WCG through the web interface. All changes made through the web interface are automatically saved to the configuration file.
3. Run
Start Scheduled Task
wcg start
Run Once Immediately (Testing)
wcg run-once
Use Custom Configuration File
wcg start --config /path/to/config.yaml
Set Log Level
wcg start --log-level DEBUG
๐ Usage
Command Line Tools
WCG provides two command line tools:
-
wcg - Main program for starting scheduled tasks
wcg start- Start the schedulerwcg run-once- Execute once immediately (for testing)
-
wcg-web - Web configuration interface
- After starting, visit http://localhost:5000 for configuration management
- All configuration changes are automatically saved to
config/config.yaml
Configuration Guide
LLM Configuration
- api_url: LLM API endpoint (supports OpenAI-compatible interfaces)
- api_key: API key
- model: Model name to use
- system_prompt (optional): Custom system prompt that defines the AI assistant's role and behavior
- Default: "ไฝ ๆฏไธไธชไธไธ็ๆๆฏๆๆกฃ็ผๅๅฉๆ๏ผๆ ้ฟๆป็ปไปฃ็ ๅๆดใ่ฏทไฝฟ็จไธญๆๅ็ญ๏ผๅนถไปฅๆธ ๆฐ็markdownๆ ผๅผ็ป็ปๅ ๅฎนใ"
- You can customize this to change the assistant's personality, language, or output style
- user_prompt_template (optional): Custom template for the user prompt sent to the LLM
- Available placeholders:
{repo_name},{branch},{organized} - Default template includes instructions for organizing changes by type (new/modified/deleted) and module
- You can customize this to change how the commit data is presented and what kind of summary you want
- Available placeholders:
Example custom prompts in config.yaml:
llm:
api_url: "https://api.openai.com/v1"
api_key: "your-api-key-here"
model: "gpt-3.5-turbo"
system_prompt: "You are a technical writer specialized in creating clear, concise commit summaries in English."
user_prompt_template: |
Summarize the following commits for {repo_name} (branch: {branch}):
Changes in the last 24 hours:
{organized}
Please create a brief summary highlighting the main changes.
GitHub Configuration
- github_token: GitHub Personal Access Token
- A valid token must be provided, otherwise you will get "401 Bad credentials" error
- Steps to create a token:
- Visit https://github.com/settings/tokens
- Click "Generate new token (classic)"
- Fill in the description and select
repopermission (full repository access) - Copy the token immediately after generation (it will only be shown once)
- Paste the token into the
github_tokenfield inconfig.yaml
repopermission is required to access private repositories- Public repositories also need a token to avoid API rate limits
- Ensure the token is not expired and has sufficient permissions
Repository Configuration
Each repository configuration includes:
- name: Repository name (format:
owner/repo) - branch: Branch to monitor
- webhook_url: Webhook URL to receive summaries
Other Settings
- schedule_time: Scheduled execution time (24-hour format:
HH:MM) - timezone: Timezone setting (default:
Asia/ShanghaiUTC+8)- Use standard IANA timezone names, such as
Asia/Shanghai,America/New_York, etc. - If server time is inaccurate, set this to specify the target timezone
- The program will execute tasks at
schedule_timeaccording to the specified timezone
- Use standard IANA timezone names, such as
- summary_dir: Local directory to save summaries
Output Format
Generated summaries use Markdown format and include:
- ๐ Title: Repository name and branch
- ๐ New Features: Added files and features
- ๐ง Code Changes: Modified files and content
- ๐๏ธ Deletions: Deleted files
- ๐ PR Links: Links to related Pull Requests
Webhook Support
WCG supports multiple webhook formats:
- Generic: Standard JSON payload
- Slack: Slack-compatible message format
- Discord: Discord embed message format
- Feishu/Lark: Feishu/Lark message card format
- WPS: WPS webhook with markdown format
To specify the webhook type, add webhook_type field in your repository configuration:
repositories:
- name: "owner/repository"
branch: "main"
webhook_url: "https://your-webhook-url.com"
webhook_type: "wps" # Options: generic, slack, discord, feishu, wps
Local Storage
Summary files are saved with the following structure:
summaries/
โโโ 2024-01/
โ โโโ 01/
โ โ โโโ owner-repo-main.md
โ โโโ 02/
โ โ โโโ owner-repo-main.md
๐ง Development
Environment Setup
# Install development dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Format code
ruff format .
# Lint code
ruff check .
Project Structure
WCG/
โโโ src/wcg/
โ โโโ __init__.py # Package initialization
โ โโโ cli.py # Command line interface
โ โโโ config.py # Configuration management
โ โโโ github_client.py # GitHub API client
โ โโโ summarizer.py # LLM summarizer
โ โโโ notifier.py # Webhook notifier
โ โโโ storage.py # Local storage
โ โโโ scheduler.py # Task scheduler
โ โโโ web.py # Web interface
โ โโโ templates/
โ โโโ index.html # Web UI template
โโโ config/
โ โโโ config.example.yaml # Configuration example
โโโ summaries/ # Summary output directory
โโโ tests/ # Test files
โโโ pyproject.toml # Project configuration
โโโ README.md # This file
๐ Troubleshooting
Common Errors and Solutions
1. "401 Bad credentials" Error
Error Message: Error fetching commits from xxx/xxx/main: 401 {"message": "Bad credentials"...}
Causes:
- GitHub token not configured or empty
- Token is invalid or expired
- Token lacks necessary permissions
Solutions:
- Check if the
github_tokenfield inconfig.yamlis correctly configured - Ensure the token is not the default value
your-github-token-here - Visit https://github.com/settings/tokens to create a new token
- Select
repopermission (full repository access) - Copy the generated token and update it in the configuration file
2. "403 Forbidden" Error
Causes:
- Token lacks permission to access a specific repository
- GitHub API rate limit reached
- Repository does not exist or no access permission
Solutions:
- Ensure the token has
repopermission - Check if you can access the target repository
- If it's a rate limit issue, wait for some time and retry
- Using an authenticated token provides higher rate limits (5000 requests/hour vs 60 requests/hour)
3. "404 Not Found" Error
Causes:
- Repository name format is incorrect
- Branch name is incorrect
- Repository does not exist or is private without access permission
Solutions:
- Check if the repository name format is correct (format:
owner/repo) - Confirm the branch name is correct (e.g.,
mainormaster) - Ensure you have permission to access the repository
๐ License
MIT License
๐ค Contributing
Issues and Pull Requests are welcome!
๐ฎ Contact
If you have any questions or suggestions, please submit an Issue.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wcg-0.4.0.tar.gz.
File metadata
- Download URL: wcg-0.4.0.tar.gz
- Upload date:
- Size: 37.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e22609576064ca7d409f3ab4532f272c0c2ec187aca2cfc27a224448e22d1d49
|
|
| MD5 |
e4c412c5974e8b140869123689f923a8
|
|
| BLAKE2b-256 |
c6bb4dbed1b2b1cec0e50c886c9de79f6e57bf108ea9cce3f0dc227680566b5b
|
File details
Details for the file wcg-0.4.0-py3-none-any.whl.
File metadata
- Download URL: wcg-0.4.0-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a8c41ed75803799a4f2b792a14bfa42c0be37a531a17d762c9739ca76d10224
|
|
| MD5 |
9b40b0bb48c3ed320db1a0c9f5fa6e81
|
|
| BLAKE2b-256 |
154f895babbc4f79575b469de9f43c7e72ecc33b3e8fefb96a82b6a4c4dc522d
|