diff --git a/community/gitlab/work_report/README.md b/community/gitlab/work_report/README.md deleted file mode 100644 index 132c0d5..0000000 --- a/community/gitlab/work_report/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# /gitlab.work_report - -Generate user weekly report based on gitlab issue and commit information - -## Purpose - -- Automatically generate work reports based on GitLab activities -- Track and summarize issues and commits within a specified time period -- Provide a structured format for work reporting - -## Usage Method - -1. Execute the command with date range: - - ```shell - /gitlab.work_report - ``` - - Example: `/gitlab.work_report 2024-03-01 2024-03-07` - -2. Or execute without parameters to generate yesterday's report: - - ```shell - /gitlab.work_report - ``` - -## Features - -- Generates reports based on: - - Issues created/updated within the specified time period - - Commits made within the specified time period -- Uses a customizable template for report formatting -- Supports both English and Chinese documentation -- Automatically detects user's GitLab username and repository information - -## Report Content - -The report includes: - -- Time period covered -- List of issues worked on -- List of commits made -- Formatted according to the template specified in configuration - -## Configuration - -The report template can be customized by modifying the `template.md` file in the `~/.chat/scripts/community/gitlab/work_report` directory. diff --git a/community/gitlab/work_report/README.zh.md b/community/gitlab/work_report/README.zh.md deleted file mode 100644 index dd29524..0000000 --- a/community/gitlab/work_report/README.zh.md +++ /dev/null @@ -1,47 +0,0 @@ -# /gitlab.work_report - -根据用户 gitlab issue 信息和 commit 信息生成用户周日报 - -## 功能目的 - -- 基于 GitLab 活动自动生成工作报告 -- 追踪和总结指定时间段内的 issues 和 commits -- 提供结构化的工作报告格式 - -## 使用方法 - -1. 带日期范围执行命令: - - ```shell - /gitlab.work_report <开始日期> <结束日期> - ``` - - 示例:`/gitlab.work_report 2024-03-01 2024-03-07` - -2. 不带参数执行命令(生成昨天的报告): - - ```shell - /gitlab.work_report - ``` - -## 功能特点 - -- 报告生成基于: - - 指定时间段内创建/更新的 issues - - 指定时间段内的 commits -- 使用可自定义的报告模板 -- 支持中英文文档 -- 自动检测用户的 GitLab 用户名和仓库信息 - -## 报告内容 - -报告包含: - -- 报告时间范围 -- 处理的 issues 列表 -- 提交的 commits 列表 -- 根据配置的模板格式化输出 - -## 配置说明 - -可以修改 `~/.chat/scripts/community/gitlab/work_report/template.md` 文件来修改报告模板。 diff --git a/community/work_report/README.md b/community/work_report/README.md new file mode 100644 index 0000000..d089881 --- /dev/null +++ b/community/work_report/README.md @@ -0,0 +1,41 @@ +# /work_report + +Generate user work report based on git issue and commit information + +## Purpose + +- Automatically generate work reports based on git activities +- Track and summarize issues and commits within a specified time period +- Provide a structured format for work reporting + +## Usage Method + +```shell +/work_report +``` + +Example: `/work_report last week` + +If no valid date parameters are provided, the system will default to generating a report from yesterday to today. + +## Features + +- Generates reports based on: + - Issues created within the specified time period + - Commits made within the specified time period by the author +- Uses a customizable template for report formatting +- Supports both English and Chinese documentation +- Automatically detects user's git username and repository information + +## Report Content + +The report includes: + +- Time period covered +- List of issues worked on +- List of commits made +- Formatted according to the configured template + +## Configuration + +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`. diff --git a/community/work_report/README.zh.md b/community/work_report/README.zh.md new file mode 100644 index 0000000..b2714ed --- /dev/null +++ b/community/work_report/README.zh.md @@ -0,0 +1,41 @@ +# /work_report + +根据用户 git issue 信息和 commit 信息生成用户工作报告 + +## 功能目的 + +- 基于 git 活动自动生成工作报告 +- 追踪和总结指定时间段内的 issues 和 commits +- 提供结构化的工作报告格式 + +## 使用方法 + +```shell +/work_report <日期描述> +``` + +示例:`/work_report 上周` + +如果没有提供有效的日期参数,系统将默认生成从昨天到今天的报告。 + +## 功能特点 + +- 报告生成基于: + - 指定时间段内创建的 issues + - 指定时间段内作者提交的 commits +- 使用可自定义的报告模板 +- 支持中英文文档 +- 自动检测用户的 git 用户名和仓库信息 + +## 报告内容 + +报告包含: + +- 报告时间范围 +- 处理的 issues 列表 +- 提交的 commits 列表 +- 根据配置的模板格式化输出 + +## 配置说明 + +可以修改脚本目录中的 `template.md` 文件来自定义报告模板。模板文件位于 `~/.chat/scripts/community/work_report/template.md`。 diff --git a/community/gitlab/work_report/command.py b/community/work_report/command.py similarity index 66% rename from community/gitlab/work_report/command.py rename to community/work_report/command.py index 9bcc31f..bcf2d5f 100755 --- a/community/gitlab/work_report/command.py +++ b/community/work_report/command.py @@ -1,8 +1,7 @@ import os -import sys -from datetime import datetime, timedelta +from datetime import date -from devchat.llm import chat +from devchat.llm import chat, chat_json from community.gitlab.git_api import ( get_commit_author, @@ -11,25 +10,7 @@ get_repo_issues, get_username, ) - -PROMPT = """ -我希望你根据以下信息生成一份从 {start_time} 到 {end_time} 的工作报告。 - -问题列表: - -{issues} - - -提交列表: - -{commits} - - -请参考以下模板内容的格式: - -""" +from lib.workflow.decorators import check_input def get_template(): @@ -54,20 +35,56 @@ def get_commits(start_time, end_time): return commits -@chat(prompt=PROMPT, stream_out=True) +@chat( + prompt=""" +我希望你根据以下信息生成一份从 {start_time} 到 {end_time} 的工作报告。 + +问题列表: + +{issues} + + +提交列表: + +{commits} + + +请参考以下模板内容的格式: + +""", + stream_out=True, +) def generate_work_report(start_time, end_time, issues, commits, template): pass -def main(): - arg = sys.argv[1] - args = arg.split(" ") - if len(args) == 3: - start_time = args[1] - end_time = args[2] - else: - end_time = datetime.now().strftime("%Y-%m-%d") - start_time = (datetime.now() - timedelta(days=1)).strftime("%Y-%m-%d") +@chat_json( + prompt=""" +今天是 {today},我希望你根据输入信息获取开始时间和结束时间。 +如果无法获取,则获取昨天到今天的时间范围。 + + +{input} + + +输出格式为 JSON 格式,如下所示: +{{ + "start_time": "2025-05-19", + "end_time": "2025-05-20" +}} +""" +) +def get_date_range(today, input): + pass + + +@check_input("请输入需要生成工作报告的时间") +def main(input): + result = get_date_range(today=date.today(), input=input) + start_time = result["start_time"] + end_time = result["end_time"] issues = get_issues(start_time, end_time) commits = get_commits(start_time, end_time) template = get_template() diff --git a/community/gitlab/work_report/command.yml b/community/work_report/command.yml similarity index 100% rename from community/gitlab/work_report/command.yml rename to community/work_report/command.yml diff --git a/community/gitlab/work_report/template.md b/community/work_report/template.md similarity index 100% rename from community/gitlab/work_report/template.md rename to community/work_report/template.md