Generate weekly/monthly reports based on Git commit records.
Trigger parsing
Parse user input and extract the following parameters:
| Parameter | Default value | Example |
|---|---|---|
| Type | Weekly report | "Weekly report" / "Monthly report" |
| User | Current git user.name | "@Zhang San" |
| Date | This week/this month | "December", "2025-01", "last 10 days" |
Parsing example:
"生成本周周报" → 类型=周报, 用户=当前, 日期=本周
"生成12月月报" → 类型=月报, 用户=当前, 日期=12月
"生成周报 @张三" → 类型=周报, 用户=张三, 日期=本周
"生成最近10天的周报" → 类型=周报, 用户=当前, 日期=最近10天
"生成用户@李四 最近7天" → 类型=周报, 用户=李四, 日期=最近7天
Execution flow
1. Detect MCP availability
Prefer using mcp__server-git__git_log, if unavailable use Bash git log。
2. Calculate date range
周报(无指定)→ 本周一 00:00 ~ 今天 23:59
月报(无指定)→ 本月1日 00:00 ~ 今天 23:59
"12月月报" → 12月1日 ~ 12月31日(或今天,若当月)
"最近N天" → N天前 00:00 ~ 今天 23:59
3. Get username
If @用户名 is specified, use that user; otherwise:
git config user.name
4. Query commit records
Use MCP (preferred):
mcp__server-git__git_log
repo_path: 当前目录
start_timestamp: 起始日期
end_timestamp: 结束日期
Then filter by author.
Use Bash (fallback):
git log --author="用户名" --since="起始日期" --until="结束日期" --pretty=format:"%h - %s (%ai)" --no-merges
5. Polish commit records
Outputting git log as-is is prohibited, the following processing must be performed:
- Merge similar commits: Merge multiple commits for the same feature into one entry
- Filter noise: Ignore meaningless commits such as Merge commits and directory deletion
- Standardize descriptions: Supplement short "update" and "modify" entries into complete descriptions
- Categorize and organize: Group by functional module or type
Output format: numbered list, without dates
1. 完成用户认证模块开发,包括登录、注册、密码重置功能
2. 添加签到日志请求详情和状态筛选功能
3. 修复打包配置问题
6. Fill template
Read assets/templates/weekly.md or monthly.md, replace variables:
| Variable | Description |
|---|---|
{{DATE_RANGE}} |
Date range, such as "2025-01-06 ~ 2025-01-10" |
{{USER}} |
Username |
{{COMMITS}} |
PolishedWork content (table or list) |
{{COMMIT_COUNT}} |
Total number of commits |
{{REPOS}} |
Involved repository names (extracted from repo_path) |
{{STAT_LINES}} |
Code line count statistics (calculated only when the template includes it) |
7. Output result
Output the filled template content to the user.
Template customization
Templates are located in assets/templates/, users can modify or add templates.
Optional variable {{STAT_LINES}}: If the template includes this variable, additionally execute:
git log --author="用户名" --since="起始" --until="结束" --shortstat --oneline | grep -E "^\s*\d+\s+file"
Aggregate insertions/deletions.
Multi-repository support
If the user specifies multiple paths, query each path separately, merge the results, and generate the report.