Skip to content

Commit cf57db6

Browse files
authored
Merge pull request #17 from LangMem/feat/cc_ci
feat: enhance issue comment generation with targeted suggestions for …
2 parents 95b31b4 + 1a3f9be commit cf57db6

File tree

1 file changed

+68
-13
lines changed

1 file changed

+68
-13
lines changed

.github/workflows/auto-comment-for-clarity.yml

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,24 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

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+
1529
name: Auto Comment for Clarity
1630
on:
1731
issues:
1832
types: [opened]
19-
discussion:
20-
types: [created]
21-
env:
22-
ANTHROPIC_BASE_URL: "https://open.bigmodel.cn/api/anthropic"
2333
jobs:
2434
auto-comment:
2535
runs-on: ubuntu-latest
@@ -44,35 +54,80 @@ jobs:
4454
// Get issue details
4555
const issueTitle = context.payload.issue.title || '';
4656
const issueBody = context.payload.issue.body || '';
47-
const issueLabels = context.payload.issue.labels?.map(label => label.name).join(', ') || '';
4857
4958
console.log('Issue Title:', issueTitle);
5059
console.log('Issue Body:', issueBody);
51-
console.log('Issue Labels:', issueLabels);
5260
53-
// Simple analysis logic
61+
// Analyze what's missing specifically
5462
const hasDetailedDescription = issueBody.length > 50 && !issueBody.includes('No response');
5563
const hasStepsToReproduce = issueBody.toLowerCase().includes('步骤') || issueBody.toLowerCase().includes('重现') || issueBody.toLowerCase().includes('reproduce');
5664
const hasEnvironmentInfo = issueBody.toLowerCase().includes('环境') || issueBody.toLowerCase().includes('版本') || issueBody.toLowerCase().includes('version');
5765
const hasExpectedBehavior = issueBody.toLowerCase().includes('期望') || issueBody.toLowerCase().includes('expected');
66+
const hasErrorDetails = issueBody.toLowerCase().includes('错误') || issueBody.toLowerCase().includes('error') || issueBody.toLowerCase().includes('异常');
5867
5968
// Check if this looks like a bug report that needs more info
6069
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+
});
62114
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 的质量和解决效率。*');
65120
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');
68122
69123
await github.rest.issues.createComment({
70124
owner,
71125
repo,
72126
issue_number,
73127
body: commentBody
74128
});
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(', '));
76131
} else {
77132
console.log('Issue has sufficient information, no comment needed');
78133
}

0 commit comments

Comments
 (0)