Skip to content

Commit fbe0d4b

Browse files
Merge pull request #28 from littleCareless/docs/pr-summary-auto-generation-spec
Docs/pr summary auto generation spec
2 parents 08a3d09 + 1f59412 commit fbe0d4b

25 files changed

+1073
-212
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,36 @@ All notable changes to this project will be documented in this file.
66

77
The format is based on [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/)
88

9+
## 0.21.1 (2025-06-13)
10+
11+
### ♻ Code Refactoring
12+
13+
- **ai-provider**: Refactor AI provider streaming request parameter processing ([1544c46](https://github.com/littleCareless/dish-ai-commit/commit/1544c46))
14+
15+
- **progress**: Optimize command progress display and user feedback ([1c098fa](https://github.com/littleCareless/dish-ai-commit/commit/1c098fa))
16+
17+
### 🎫 Chores
18+
19+
- **i18n**: Added internationalized text related to PR summary generation progress ([e437a0c](https://github.com/littleCareless/dish-ai-commit/commit/e437a0c))
20+
21+
- **release**: Release 0.21.0 Version ([f79a70c](https://github.com/littleCareless/dish-ai-commit/commit/f79a70c))
22+
23+
# 0.21.0 (2025-06-13)
24+
25+
### ✨ Features
26+
27+
- **ai-provider**: Implement PR summary generation for AI provider ([c0c9d48](https://github.com/littleCareless/dish-ai-commit/commit/c0c9d48))
28+
- **config**: Add PR summary config option ([d933c69](https://github.com/littleCareless/dish-ai-commit/commit/d933c69))
29+
- **extension**: Add PR summary generation ([d9b1d21](https://github.com/littleCareless/dish-ai-commit/commit/d9b1d21))
30+
- **pr-summary**: Add PR summary generation ([5867855](https://github.com/littleCareless/dish-ai-commit/commit/5867855))
31+
- **pr-summary**: Added the function of generating PR summary ([78c92c1](https://github.com/littleCareless/dish-ai-commit/commit/78c92c1))
32+
- **scm**: Added the function of obtaining commit log and branch list ([be86233](https://github.com/littleCareless/dish-ai-commit/commit/be86233))
33+
34+
### 🎫 Chores
35+
36+
- **i18n**: Updated internationalization files to support new features such as PR summary ([9a29abb](https://github.com/littleCareless/dish-ai-commit/commit/9a29abb))
37+
- **release**: Release 0.20.2 version ([08a3d09](https://github.com/littleCareless/dish-ai-commit/commit/08a3d09))
38+
939
## 0.20.2 (2025-06-12)
1040

1141
### 🎫 Chores

CHANGELOG.zh-CN.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,34 @@ All notable changes to this project will be documented in this file.
66

77
The format is based on [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/)
88

9+
## 0.21.1 (2025-06-13)
10+
11+
### ♻ Code Refactoring
12+
13+
- **ai-provider**: 重构 AI 提供程序流式请求参数处理 ([1544c46](https://github.com/littleCareless/dish-ai-commit/commit/1544c46))
14+
- **progress**: 优化命令进度显示与用户反馈 ([1c098fa](https://github.com/littleCareless/dish-ai-commit/commit/1c098fa))
15+
16+
### 🎫 Chores
17+
18+
- **i18n**: 新增 PR 摘要生成进度相关的国际化文案 ([e437a0c](https://github.com/littleCareless/dish-ai-commit/commit/e437a0c))
19+
- **release**: 发布 0.21.0 版本 ([f79a70c](https://github.com/littleCareless/dish-ai-commit/commit/f79a70c))
20+
21+
# 0.21.0 (2025-06-13)
22+
23+
### ✨ Features
24+
25+
- **ai-provider**: 为 AI 提供程序实现 PR 摘要生成功能 ([c0c9d48](https://github.com/littleCareless/dish-ai-commit/commit/c0c9d48))
26+
- **config**: 添加 PR 摘要配置选项 ([d933c69](https://github.com/littleCareless/dish-ai-commit/commit/d933c69))
27+
- **extension**: 添加生成 PR 摘要功能 ([d9b1d21](https://github.com/littleCareless/dish-ai-commit/commit/d9b1d21))
28+
- **pr-summary**: 添加生成 PR 摘要功能 ([5867855](https://github.com/littleCareless/dish-ai-commit/commit/5867855))
29+
- **pr-summary**: 添加生成 PR 摘要功能 ([78c92c1](https://github.com/littleCareless/dish-ai-commit/commit/78c92c1))
30+
- **scm**: 新增获取提交日志与分支列表功能 ([be86233](https://github.com/littleCareless/dish-ai-commit/commit/be86233))
31+
32+
### 🎫 Chores
33+
34+
- **i18n**: 更新国际化文件,支持 PR 摘要等新功能 ([9a29abb](https://github.com/littleCareless/dish-ai-commit/commit/9a29abb))
35+
- **release**: 发布 0.20.2 版本 ([08a3d09](https://github.com/littleCareless/dish-ai-commit/commit/08a3d09))
36+
937
## 0.20.2 (2025-06-12)
1038

1139
### 🎫 Chores

i18n/en.json

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
"no.changes.selected": "No changes selected! Please select files to analyze",
105105
"no.changes.found": "No changes found in selected files",
106106
"please.select.valid.files": "Some selected files are invalid, please reselect files for review",
107-
"no.changes.found": "No changes found for review",
108107
"review.file.failed": "Failed to review file: {0}",
109108
"code.review.failed": "Code review failed: {0}",
110109
"svn.no.files.selected": "No files selected to commit",
@@ -157,5 +156,25 @@
157156
"confirm.ai.provider.tos.cancel": "Cancel",
158157
"confirm.ai.provider.tos.message": "Dish AI features can send code snippets, diffs, and other context to your selected AI provider for analysis.",
159158
"user.cancelled.operation.log": "User cancelled the operation",
160-
"user.cancelled.operation.error": "Operation cancelled by user"
159+
"user.cancelled.operation.error": "Operation cancelled by user",
160+
"pr.summary.git.only": "PR Summary generation is only available for Git repositories",
161+
"pr.summary.no.commits": "No commits found to generate PR summary",
162+
"progress.generating.pr.summary": "Generating PR summary...",
163+
"detecting.scm.provider": "Detecting SCM provider...",
164+
"fetching.branches": "Fetching branches...",
165+
"fetching.commit.log": "Fetching commit log...",
166+
"validating.model": "Validating model...",
167+
"analyzing.commits": "Analyzing commits...",
168+
"pr.summary.title": "PR Summary",
169+
"pr.summary.generated": "PR Summary generated successfully and opened in a new tab",
170+
"pr.summary.generation.failed": "Failed to generate PR summary",
171+
"pr.summary.generation.failed.error": "Failed to generate PR summary: {0}",
172+
"command.pr.summary.failed": "PR Summary generation command failed: {0}",
173+
"provider.does.not.support.feature": "Provider {0} does not support {1}.",
174+
"svn.log.failed": "Failed to get SVN commit log: {0}",
175+
"git.branch.list.failed": "Failed to get Git branch list: {0}",
176+
"pr.summary.select.base.branch.placeholder": "Select base branch to compare with (current: {0})",
177+
"pr.summary.select.base.branch.title": "Select Base Branch for PR Summary",
178+
"pr.summary.base.branch.selection.cancelled": "Base branch selection cancelled. PR summary generation aborted.",
179+
"pr.summary.no.branches.found": "No branches found in the repository. Using default base branch."
161180
}

i18n/zh-cn.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,8 @@
9191
"dashscope.apiKey.missing": "DashScope API Key 未配置。是否现在配置?",
9292
"doubao.apiKey.missing": "豆包 API Key 未配置。是否现在配置?",
9393
"reviewing.code": "正在进行代码评审",
94-
"getting.file.changes": "正在获取文件变更...",
9594
"no.valid.changes.selected": "未选择有效的待评审变更",
9695
"reviewing.file": "评审文件:{0}",
97-
"preparing.results": "正在准备评审结果...",
9896
"review.all.failed": "所有文件评审失败",
9997
"review.complete.count": "已完成 {0} 个文件的代码评审",
10098
"review.results.title": "代码评审结果",
@@ -121,7 +119,6 @@
121119
"branch.name.git.only": "分支名称生成功能仅适用于Git仓库",
122120
"command.branch.name.failed": "分支名称生成命令执行失败:{0}",
123121
"please.select.valid.files": "选择的文件中包含无效项,请重新选择要评审的文件",
124-
"no.changes.found": "未找到需要评审的变更",
125122
"review.file.failed": "评审文件失败: {0}",
126123
"code.review.failed": "代码评审失败: {0}",
127124
"svn.no.files.selected": "未选择要提交的文件",
@@ -161,5 +158,25 @@
161158
"confirm.ai.provider.tos.cancel": "取消",
162159
"confirm.ai.provider.tos.message": "Dish AI 功能可以将代码片段、差异和其他上下文发送到您选择的 AI 提供商进行分析。",
163160
"user.cancelled.operation.log": "用户取消了操作",
164-
"user.cancelled.operation.error": "操作已被用户取消"
161+
"user.cancelled.operation.error": "操作已被用户取消",
162+
"pr.summary.git.only": "PR摘要生成功能仅适用于Git仓库",
163+
"pr.summary.no.commits": "未找到可用于生成PR摘要的提交记录",
164+
"progress.generating.pr.summary": "正在生成PR摘要...",
165+
"detecting.scm.provider": "正在检测SCM提供商...",
166+
"fetching.branches": "正在获取分支列表...",
167+
"fetching.commit.log": "正在获取提交日志...",
168+
"validating.model": "正在验证模型...",
169+
"analyzing.commits": "正在分析提交记录...",
170+
"pr.summary.title": "PR摘要",
171+
"pr.summary.generated": "PR摘要已成功生成并在新标签页中打开",
172+
"pr.summary.generation.failed": "生成PR摘要失败",
173+
"pr.summary.generation.failed.error": "生成PR摘要失败: {0}",
174+
"command.pr.summary.failed": "PR摘要生成命令执行失败: {0}",
175+
"provider.does.not.support.feature": "提供商 {0} 不支持 {1} 功能。",
176+
"svn.log.failed": "获取 SVN 提交日志失败: {0}",
177+
"git.branch.list.failed": "获取 Git 分支列表失败: {0}",
178+
"pr.summary.select.base.branch.placeholder": "选择要对比的基础分支 (当前: {0})",
179+
"pr.summary.select.base.branch.title": "选择PR摘要的基础分支",
180+
"pr.summary.base.branch.selection.cancelled": "已取消选择基础分支。PR摘要生成已中止。",
181+
"pr.summary.no.branches.found": "仓库中未找到分支。将使用默认基础分支。"
165182
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "dish-ai-commit",
33
"displayName": "Dish AI Commit Message Gen",
44
"description": "🤖 由 AI 提供支持的 VSCode 扩展,用于生成标准化的 Git/SVN 提交消息 - 🤖 AI-Powered VSCode extension for generating standardized Git/SVN commit messages. ✨ Supports multiple AI services: OpenAI, ChatGPT, Ollama, Zhipu, DashScope, Doubao, Gemini and VS Code built-in AI. 🌍 Multi-language support (EN/CN/JP/KR/Other). 📊 Auto-generate weekly reports.",
5-
"version": "0.20.2",
5+
"version": "0.21.1",
66
"engines": {
77
"node": ">= 18.20.8",
88
"pnpm": ">= 10.0.0",
@@ -88,6 +88,13 @@
8888
"category": "[Dish AI Commit]",
8989
"icon": "/images/icon.svg",
9090
"description": "使用 AI 生成Git分支名称"
91+
},
92+
{
93+
"command": "dish-ai-commit.generatePRSummary",
94+
"title": "[Dish] Generate PR Summary with AI",
95+
"category": "[Dish AI Commit]",
96+
"icon": "/images/icon.svg",
97+
"description": "使用 AI 生成 PR 摘要"
9198
}
9299
],
93100
"configuration": {
@@ -257,6 +264,26 @@
257264
"type": "string",
258265
"default": "",
259266
"description": "Custom system prompt for branch name generation / 分支名称生成的自定义系统提示语"
267+
},
268+
"dish-ai-commit.features.prSummary.baseBranch": {
269+
"type": "string",
270+
"default": "origin/main",
271+
"description": "Base branch for comparing commits to generate PR summary / 用于比较提交以生成PR摘要的基础分支"
272+
},
273+
"dish-ai-commit.features.prSummary.headBranch": {
274+
"type": "string",
275+
"default": "HEAD",
276+
"description": "Head branch for comparing commits to generate PR summary / 用于比较提交以生成PR摘要的头部分支"
277+
},
278+
"dish-ai-commit.features.prSummary.systemPrompt": {
279+
"type": "string",
280+
"default": "",
281+
"description": "Custom system prompt for PR summary generation / PR摘要生成的自定义系统提示语"
282+
},
283+
"svn-commit-gen.commitLogLimit": {
284+
"type": "number",
285+
"default": 20,
286+
"description": "The maximum number of commit logs to fetch for SVN when no specific range is provided. / 当未提供特定范围时,为 SVN 获取提交日志的最大数量。"
260287
}
261288
}
262289
},
@@ -291,6 +318,11 @@
291318
"command": "dish-ai-commit.selectModel",
292319
"when": "scmProvider =~ /(git|svn)/",
293320
"group": "2_z_dish@5"
321+
},
322+
{
323+
"command": "dish-ai-commit.generatePRSummary",
324+
"when": "scmProvider == git",
325+
"group": "2_z_dish@6"
294326
}
295327
],
296328
"scm/resourceState/context": [
@@ -318,6 +350,11 @@
318350
"command": "dish-ai-commit.selectModel",
319351
"when": "((config.svn.enabled && scmProvider == svn) || (config.git.enabled && scmProvider == git)) && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts && scmResourceGroup != remotechanges",
320352
"group": "2_z_dish@5"
353+
},
354+
{
355+
"command": "dish-ai-commit.generatePRSummary",
356+
"when": "config.git.enabled && scmProvider == git && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts && scmResourceGroup != remotechanges",
357+
"group": "2_z_dish@6"
321358
}
322359
],
323360
"scm/resourceFolder/context": [
@@ -345,6 +382,11 @@
345382
"command": "dish-ai-commit.selectModel",
346383
"when": "((config.svn.enabled && scmProvider == svn) || (config.git.enabled && scmProvider == git)) && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts && scmResourceGroup != remotechanges",
347384
"group": "inline"
385+
},
386+
{
387+
"command": "dish-ai-commit.generatePRSummary",
388+
"when": "config.git.enabled && scmProvider == git && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts && scmResourceGroup != remotechanges",
389+
"group": "inline"
348390
}
349391
],
350392
"commandPalette": [
@@ -362,6 +404,9 @@
362404
},
363405
{
364406
"command": "dish-ai-commit.reviewCode"
407+
},
408+
{
409+
"command": "dish-ai-commit.generatePRSummary"
365410
}
366411
]
367412
}

src/ai/providers/abstract-ai-provider.ts

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,31 @@ export abstract class AbstractAIProvider implements AIProvider {
5252
);
5353
}
5454
}
55-
/**
55+
/**
5656
* 生成提交信息 (流式)
5757
* @param params - AI请求参数
5858
* @returns 一个Promise,解析为一个异步迭代器,用于逐块生成提交信息
5959
* @remarks 此方法为新增,AIProvider接口也需要相应更新
6060
*/
61-
async generateCommitStream(params: AIRequestParams): Promise<AsyncIterable<string>> {
61+
async generateCommitStream(
62+
params: AIRequestParams
63+
): Promise<AsyncIterable<string>> {
6264
try {
63-
console.log("params for stream", params);
64-
const systemPrompt = getSystemPrompt(params);
6565
// 注意:流式请求的重试逻辑可能与非流式请求不同。
6666
// 这里直接调用 executeAIStreamRequest,具体的重试和错误处理
6767
// 应该在 executeAIStreamRequest 的实现中或专门的流式重试辅助函数中处理。
68-
return this.executeAIStreamRequest(
69-
systemPrompt,
70-
"", // userPrompt
71-
params.diff, // userContent
72-
params,
73-
{
74-
temperature: 0.3, // 提交信息推荐温度值 0.3
75-
// maxTokens 可以在这里设置,如果需要的话
76-
}
77-
);
68+
// systemPrompt, userPrompt, userContent 将由 executeAIStreamRequest 的实现
69+
// 从 params 中获取或计算。
70+
return this.executeAIStreamRequest(params, {
71+
temperature: 0.3, // 提交信息推荐温度值 0.3
72+
// maxTokens 可以在这里设置,如果需要的话
73+
});
7874
} catch (error) {
7975
// 流的错误可能在迭代过程中发生,这里的 catch 可能只捕获初始设置错误
8076
// 需要在调用方迭代流时也处理错误
8177
throw new Error(
82-
formatMessage("generation.failed", [ // 或者一个新的i18n key如 "streamGeneration.failed"
78+
formatMessage("generation.failed", [
79+
// 或者一个新的i18n key如 "streamGeneration.failed"
8380
error instanceof Error ? error.message : String(error),
8481
])
8582
);
@@ -331,20 +328,18 @@ export abstract class AbstractAIProvider implements AIProvider {
331328
): Promise<{ content: string; usage?: any; jsonContent?: any }>;
332329

333330
/**
334-
* 需要由具体提供者实现的核心流式方法
335-
* 执行AI流式请求并返回一个异步迭代器
331+
* 需要由具体提供者实现的核心流式方法。
332+
* 执行AI流式请求并返回一个异步迭代器。
333+
* 实现类应从此方法内部的 `params` 对象中获取或生成 `systemPrompt`, `userPrompt`, 和 `userContent`。
334+
* - `systemPrompt` 通常通过调用 `getSystemPrompt(params)` 生成。
335+
* - `userPrompt` 通常取自 `params.additionalContext` (如果存在),否则为空字符串。
336+
* - `userContent` 通常取自 `params.diff`。
336337
*
337-
* @param systemPrompt - 系统提示内容
338-
* @param userPrompt - 用户提示内容
339-
* @param userContent - 用户内容
340-
* @param params - 请求参数
341-
* @param options - 额外选项
342-
* @returns Promise<AsyncIterable<string>>
338+
* @param params - AI请求参数,包含构建提示所需的所有信息及模型配置。
339+
* @param options - 额外选项,如 `temperature` 和 `maxTokens`。
340+
* @returns 一个Promise,解析为一个异步迭代器,用于逐块生成内容。
343341
*/
344342
protected abstract executeAIStreamRequest(
345-
systemPrompt: string,
346-
userPrompt: string,
347-
userContent: string,
348343
params: AIRequestParams,
349344
options?: {
350345
temperature?: number;

0 commit comments

Comments
 (0)