feat(ai-review comment): 集中更新單一審查留言
This commit is contained in:
+19
-6
@@ -1,7 +1,7 @@
|
||||
import path from 'path';
|
||||
import { GITEA_REPOSITORY, PR_NUMBER, PR_HEAD_BRANCH, PR_BASE_BRANCH, getLLMConfig, FINDINGS_PATH, EXCLUSIONS_PATH } from './config.js';
|
||||
import { loadRoles, getRoleIntro } from './roles.js';
|
||||
import { getPRDiff, postComment, getCommitMessageBySha, getBotReviewOutcome, shouldSkipBotCommit } from './gitea.js';
|
||||
import { getPRDiff, postComment, updateComment, getCommitMessageBySha, getBotReviewOutcome, shouldSkipBotCommit } from './gitea.js';
|
||||
import { analyzeWithRole, loadOldFindings, mergeFindings, sortByLevel, deduplicateWithAI, loadExclusions, applyExclusions, filterFalsePositivesWithAI } from './findings.js';
|
||||
import { saveFindings, postOldFindingsComment, postNewNonCriticalComment, postNewCriticalComments } from './comments.js';
|
||||
import { cloneRepo, commitAndPush, getRepoState } from './git.js';
|
||||
@@ -63,9 +63,22 @@ async function main() {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
let reviewComment = null;
|
||||
let reviewCommentBody = getRoleIntro(roles) + `\n\n> 🔍 服務:${provider} 模型:${model}`;
|
||||
const appendReviewComment = async (body) => {
|
||||
if (!body) return null;
|
||||
if (!reviewComment?.id) {
|
||||
reviewCommentBody = body;
|
||||
reviewComment = await postComment(reviewCommentBody);
|
||||
return reviewComment;
|
||||
}
|
||||
reviewCommentBody += `\n\n---\n\n${body}`;
|
||||
reviewComment = await updateComment(reviewComment.id, reviewCommentBody);
|
||||
return reviewComment;
|
||||
};
|
||||
|
||||
try {
|
||||
const intro = getRoleIntro(roles) + `\n\n> 🔍 服務:${provider} 模型:${model}`;
|
||||
await postComment(intro);
|
||||
reviewComment = await postComment(reviewCommentBody);
|
||||
ok('角色介紹 comment 發布成功');
|
||||
} catch (e) {
|
||||
warn(`comment 發布失敗(繼續執行): ${e.message}`);
|
||||
@@ -111,9 +124,9 @@ async function main() {
|
||||
const reviewDir = repoDir || WORKSPACE;
|
||||
saveFindings(WORKSPACE, filtered, reviewDir);
|
||||
try {
|
||||
await postOldFindingsComment(filtered);
|
||||
await postNewNonCriticalComment(filtered);
|
||||
await postNewCriticalComments(filtered);
|
||||
await postOldFindingsComment(filtered, { postIssue: appendReviewComment });
|
||||
await postNewNonCriticalComment(filtered, { postIssue: appendReviewComment });
|
||||
await postNewCriticalComments(filtered, { postInline: null, postIssue: appendReviewComment });
|
||||
ok('Step5 完成');
|
||||
} catch (e) {
|
||||
warn(`comment 發布失敗(繼續執行): ${e.message}`);
|
||||
|
||||
Reference in New Issue
Block a user