Skip to content

Commit cdd06a8

Browse files
committed
refactor: update work report command to improve date handling and enhance documentation
1 parent a03e9c8 commit cdd06a8

7 files changed

Lines changed: 131 additions & 126 deletions

File tree

community/gitlab/work_report/README.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

community/gitlab/work_report/README.zh.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

community/work_report/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# /work_report
2+
3+
Generate user work report based on git issue and commit information
4+
5+
## Purpose
6+
7+
- Automatically generate work reports based on git activities
8+
- Track and summarize issues and commits within a specified time period
9+
- Provide a structured format for work reporting
10+
11+
## Usage Method
12+
13+
```shell
14+
/work_report <date_description>
15+
```
16+
17+
Example: `/work_report last week`
18+
19+
If no valid date parameters are provided, the system will default to generating a report from yesterday to today.
20+
21+
## Features
22+
23+
- Generates reports based on:
24+
- Issues created within the specified time period
25+
- Commits made within the specified time period by the author
26+
- Uses a customizable template for report formatting
27+
- Supports both English and Chinese documentation
28+
- Automatically detects user's git username and repository information
29+
30+
## Report Content
31+
32+
The report includes:
33+
34+
- Time period covered
35+
- List of issues worked on
36+
- List of commits made
37+
- Formatted according to the configured template
38+
39+
## Configuration
40+
41+
The report template can be customized by modifying the `template.md` file in the script directory. The template file is located at `~/.chat/scripts/community/work_report/template.md`.

community/work_report/README.zh.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# /work_report
2+
3+
根据用户 git issue 信息和 commit 信息生成用户工作报告
4+
5+
## 功能目的
6+
7+
- 基于 git 活动自动生成工作报告
8+
- 追踪和总结指定时间段内的 issues 和 commits
9+
- 提供结构化的工作报告格式
10+
11+
## 使用方法
12+
13+
```shell
14+
/work_report <日期描述>
15+
```
16+
17+
示例:`/work_report 上周`
18+
19+
如果没有提供有效的日期参数,系统将默认生成从昨天到今天的报告。
20+
21+
## 功能特点
22+
23+
- 报告生成基于:
24+
- 指定时间段内创建的 issues
25+
- 指定时间段内作者提交的 commits
26+
- 使用可自定义的报告模板
27+
- 支持中英文文档
28+
- 自动检测用户的 git 用户名和仓库信息
29+
30+
## 报告内容
31+
32+
报告包含:
33+
34+
- 报告时间范围
35+
- 处理的 issues 列表
36+
- 提交的 commits 列表
37+
- 根据配置的模板格式化输出
38+
39+
## 配置说明
40+
41+
可以修改脚本目录中的 `template.md` 文件来自定义报告模板。模板文件位于 `~/.chat/scripts/community/work_report/template.md`
Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import os
2-
import sys
3-
from datetime import datetime, timedelta
2+
from datetime import date
43

5-
from devchat.llm import chat
4+
from devchat.llm import chat, chat_json
65

76
from community.gitlab.git_api import (
87
get_commit_author,
@@ -11,25 +10,7 @@
1110
get_repo_issues,
1211
get_username,
1312
)
14-
15-
PROMPT = """
16-
我希望你根据以下信息生成一份从 {start_time} 到 {end_time} 的工作报告。
17-
18-
问题列表:
19-
<issues>
20-
{issues}
21-
</issues>
22-
23-
提交列表:
24-
<commits>
25-
{commits}
26-
</commits>
27-
28-
请参考以下模板内容的格式:
29-
<template>
30-
{template}
31-
</template>
32-
"""
13+
from lib.workflow.decorators import check_input
3314

3415

3516
def get_template():
@@ -54,20 +35,56 @@ def get_commits(start_time, end_time):
5435
return commits
5536

5637

57-
@chat(prompt=PROMPT, stream_out=True)
38+
@chat(
39+
prompt="""
40+
我希望你根据以下信息生成一份从 {start_time} 到 {end_time} 的工作报告。
41+
42+
问题列表:
43+
<issues>
44+
{issues}
45+
</issues>
46+
47+
提交列表:
48+
<commits>
49+
{commits}
50+
</commits>
51+
52+
请参考以下模板内容的格式:
53+
<template>
54+
{template}
55+
</template>
56+
""",
57+
stream_out=True,
58+
)
5859
def generate_work_report(start_time, end_time, issues, commits, template):
5960
pass
6061

6162

62-
def main():
63-
arg = sys.argv[1]
64-
args = arg.split(" ")
65-
if len(args) == 3:
66-
start_time = args[1]
67-
end_time = args[2]
68-
else:
69-
end_time = datetime.now().strftime("%Y-%m-%d")
70-
start_time = (datetime.now() - timedelta(days=1)).strftime("%Y-%m-%d")
63+
@chat_json(
64+
prompt="""
65+
今天是 {today},我希望你根据输入信息获取开始时间和结束时间。
66+
如果无法获取,则获取昨天到今天的时间范围。
67+
68+
<input>
69+
{input}
70+
</input>
71+
72+
输出格式为 JSON 格式,如下所示:
73+
{{
74+
"start_time": "2025-05-19",
75+
"end_time": "2025-05-20"
76+
}}
77+
"""
78+
)
79+
def get_date_range(today, input):
80+
pass
81+
82+
83+
@check_input("请输入需要生成工作报告的时间")
84+
def main(input):
85+
result = get_date_range(today=date.today(), input=input)
86+
start_time = result["start_time"]
87+
end_time = result["end_time"]
7188
issues = get_issues(start_time, end_time)
7289
commits = get_commits(start_time, end_time)
7390
template = get_template()

0 commit comments

Comments
 (0)