Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions community/gitlab/work_report/README.md

This file was deleted.

47 changes: 0 additions & 47 deletions community/gitlab/work_report/README.zh.md

This file was deleted.

41 changes: 41 additions & 0 deletions community/work_report/README.md
Original file line number Diff line number Diff line change
@@ -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 <date_description>
```

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`.
41 changes: 41 additions & 0 deletions community/work_report/README.zh.md
Original file line number Diff line number Diff line change
@@ -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`。
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -11,25 +10,7 @@
get_repo_issues,
get_username,
)

PROMPT = """
我希望你根据以下信息生成一份从 {start_time} 到 {end_time} 的工作报告。

问题列表:
<issues>
{issues}
</issues>

提交列表:
<commits>
{commits}
</commits>

请参考以下模板内容的格式:
<template>
{template}
</template>
"""
from lib.workflow.decorators import check_input


def get_template():
Expand All @@ -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>
{issues}
</issues>

提交列表:
<commits>
{commits}
</commits>

请参考以下模板内容的格式:
<template>
{template}
</template>
""",
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>
{input}
</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()
Expand Down