admin cccd5face6 精简 weekly-report README,只保留技能特有配置说明
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 15:50:39 +08:00

80 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# weekly-report
统计项目过去 7 天的 commit 和 PR为每位协作者生成个人工作日志和项目整体进度报告通过 SMTP 发送邮件。
> 适用于自建 Gitea 仓库,不依赖 `gh` CLI。
## 前置要求
- Python 3.8+
- 项目 `origin` 指向 Gitea 实例
- 有可用的 SMTP 邮件账号
## 配置文件
在**被统计项目**的根目录创建 `report-config.json`(可提交到 git
```json
{
"recipients": ["boss@company.com", "team@company.com"],
"project_name": "项目名称",
"smtp_host": "smtphz.qiye.163.com",
"smtp_port": 994
}
```
| 字段 | 必填 | 说明 |
|------|------|------|
| `recipients` | 是 | 收件人邮箱列表 |
| `project_name` | 是 | 显示在邮件标题中 |
| `smtp_host` | 否 | 内置服务商可省略(见下表) |
| `smtp_port` | 否 | 内置服务商可省略 |
### 内置 SMTP 服务商
| 邮箱后缀 | 服务器 | 端口 |
|----------|--------|------|
| `@gmail.com` | smtp.gmail.com | 587 |
| `@qq.com` | smtp.qq.com | 465 |
| `@163.com` | smtp.163.com | 465 |
| `@126.com` | smtp.126.com | 465 |
| `@outlook.com` / `@hotmail.com` | smtp.office365.com | 587 |
企业自定义域名需手动填写 `smtp_host``smtp_port`
## 环境变量
```bash
export SMTP_USER=your@email.com
export SMTP_PASSWORD=your-auth-code
# 私有 Gitea 仓库需要(公开仓库忽略)
export GITEA_TOKEN=your-gitea-token
```
`GITEA_TOKEN` 在 Gitea 中生成:`头像 → 设置 → 应用 → 管理 Access Token`,权限勾选 `repository: Read`
## 定时发送
`crontab -e` 添加一行(每周五 18:00
```
0 18 * * 5 cd /path/to/your-project && SMTP_USER=xxx SMTP_PASSWORD=xxx claude -p "/weekly-report" >> ~/weekly_report.log 2>&1
```
Windows 用任务计划程序,参数设为:
```
-l -c "cd /e/your-project && SMTP_USER=xxx SMTP_PASSWORD=xxx claude -p '/weekly-report'"
```
## 常见问题
**Q发送失败提示认证错误**
A需使用授权码而非登录密码。QQ/163 在邮箱设置中开启 SMTP 并生成授权码Gmail 需开启两步验证后生成应用专用密码。
**Q没有 PR 数据**
A只有通过 Gitea 创建并合并的 Pull Request 才会被统计,直接 `git push` 不产生 PR 记录。
**Q私有仓库报 401**
A设置 `GITEA_TOKEN` 环境变量。