12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
+ # Copyright 2024-2026 the original author or authors.
16
+ #
17
+ # Licensed under the Apache License, Version 2.0 (the "License");
18
+ # you may not use this file except in compliance with the License.
19
+ # You may obtain a copy of the License at
20
+ #
21
+ # https://www.apache.org/licenses/LICENSE-2.0
22
+ #
23
+ # Unless required by applicable law or agreed to in writing, software
24
+ # distributed under the License is distributed on an "AS IS" BASIS,
25
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ # See the License for the specific language governing permissions and
27
+ # limitations under the License.
28
+
15
29
name : Auto Comment for Clarity
16
30
on :
17
31
issues :
18
32
types : [opened]
19
- discussion :
20
- types : [created]
21
- env :
22
- ANTHROPIC_BASE_URL : " https://open.bigmodel.cn/api/anthropic"
23
33
jobs :
24
34
auto-comment :
25
35
runs-on : ubuntu-latest
@@ -44,35 +54,80 @@ jobs:
44
54
// Get issue details
45
55
const issueTitle = context.payload.issue.title || '';
46
56
const issueBody = context.payload.issue.body || '';
47
- const issueLabels = context.payload.issue.labels?.map(label => label.name).join(', ') || '';
48
57
49
58
console.log('Issue Title:', issueTitle);
50
59
console.log('Issue Body:', issueBody);
51
- console.log('Issue Labels:', issueLabels);
52
60
53
- // Simple analysis logic
61
+ // Analyze what's missing specifically
54
62
const hasDetailedDescription = issueBody.length > 50 && !issueBody.includes('No response');
55
63
const hasStepsToReproduce = issueBody.toLowerCase().includes('步骤') || issueBody.toLowerCase().includes('重现') || issueBody.toLowerCase().includes('reproduce');
56
64
const hasEnvironmentInfo = issueBody.toLowerCase().includes('环境') || issueBody.toLowerCase().includes('版本') || issueBody.toLowerCase().includes('version');
57
65
const hasExpectedBehavior = issueBody.toLowerCase().includes('期望') || issueBody.toLowerCase().includes('expected');
66
+ const hasErrorDetails = issueBody.toLowerCase().includes('错误') || issueBody.toLowerCase().includes('error') || issueBody.toLowerCase().includes('异常');
58
67
59
68
// Check if this looks like a bug report that needs more info
60
69
const isBugReport = issueTitle.toLowerCase().includes('bug') || issueTitle.toLowerCase().includes('错误');
61
- const needsMoreInfo = isBugReport && (!hasDetailedDescription || !hasStepsToReproduce || !hasEnvironmentInfo);
70
+ const hasVeryShortDescription = issueBody.trim().length < 30 || issueBody === 'No response' || issueBody.includes('这个怎么用') || issueBody.includes('不知道为什么');
71
+
72
+ // Generate dynamic comment based on what's missing
73
+ const missingItems = [];
74
+ const suggestions = [];
75
+
76
+ if (hasVeryShortDescription) {
77
+ missingItems.push('详细的问题描述');
78
+ suggestions.push('请详细描述您遇到的具体问题,而不是简单的一句话');
79
+ }
80
+
81
+ if (isBugReport && !hasStepsToReproduce) {
82
+ missingItems.push('重现步骤');
83
+ suggestions.push('请提供能够重现问题的具体操作步骤');
84
+ }
85
+
86
+ if (isBugReport && !hasErrorDetails) {
87
+ missingItems.push('错误信息');
88
+ suggestions.push('请提供完整的错误信息、异常堆栈或错误日志');
89
+ }
90
+
91
+ if (isBugReport && !hasEnvironmentInfo) {
92
+ missingItems.push('环境信息');
93
+ suggestions.push('请提供 mem4j 版本、Java 版本、操作系统等环境信息');
94
+ }
95
+
96
+ if (!hasExpectedBehavior && isBugReport) {
97
+ missingItems.push('期望行为');
98
+ suggestions.push('请描述您期望的正确行为应该是什么');
99
+ }
100
+
101
+ // Only comment if there are missing items
102
+ if (missingItems.length > 0) {
103
+ let commentLines = [
104
+ '👋 感谢您提交这个 issue!',
105
+ '',
106
+ '为了更好地帮助您解决问题,我发现以下信息需要补充:',
107
+ ''
108
+ ];
109
+
110
+ // Add specific missing items
111
+ missingItems.forEach((item, index) => {
112
+ commentLines.push(`${index + 1}. **${item}** - ${suggestions[index]}`);
113
+ });
62
114
63
- // Also check for very short descriptions
64
- const hasVeryShortDescription = issueBody.trim().length < 20 || issueBody === 'No response' || issueBody.includes('这个怎么用');
115
+ commentLines.push('');
116
+ commentLines.push('请编辑您的原始 issue 来添加这些信息,这将帮助我们更快地定位和解决问题。🙏');
117
+ commentLines.push('');
118
+ commentLines.push('---');
119
+ commentLines.push('*这是一个自动生成的提醒,旨在提高 issue 的质量和解决效率。*');
65
120
66
- if (needsMoreInfo || hasVeryShortDescription) {
67
- const commentBody = '👋 感谢您提交这个 issue!\\n\\n为了更好地帮助您解决问题,请补充以下信息:\\n\\n- [ ] **详细的问题描述**:请详细描述您遇到的具体问题\\n- [ ] **重现步骤**:请提供能够重现问题的具体步骤\\n- [ ] **期望的行为**:请描述您期望的正确行为应该是什么\\n- [ ] **实际的行为**:请描述实际发生了什么\\n- [ ] **环境信息**:\\n - mem4j 版本\\n - Java 版本\\n - 操作系统\\n - 其他相关配置\\n\\n请编辑您的原始 issue 来添加这些信息,这将帮助我们更快地定位和解决问题。🙏';
121
+ const commentBody = commentLines.join('\n');
68
122
69
123
await github.rest.issues.createComment({
70
124
owner,
71
125
repo,
72
126
issue_number,
73
127
body: commentBody
74
128
});
75
- console.log('Posted clarity request comment to issue #' + issue_number);
129
+ console.log('Posted targeted clarity request comment to issue #' + issue_number);
130
+ console.log('Missing items:', missingItems.join(', '));
76
131
} else {
77
132
console.log('Issue has sufficient information, no comment needed');
78
133
}
0 commit comments