feat(ai-review 對話收斂): 讀 PR review 留言判斷解決狀態並收斂 findings
This commit is contained in:
+16
-1
@@ -3,6 +3,7 @@ import { GITEA_REPOSITORY, PR_NUMBER, PR_HEAD_BRANCH, PR_BASE_BRANCH, getLLMConf
|
||||
import { loadRoles, getRoleIntro } from './roles.js';
|
||||
import { getPRDiff, postComment, getCommitMessageBySha, getBotReviewOutcome, shouldSkipBotCommit } from './gitea.js';
|
||||
import { analyzeWithRole, loadOldFindings, mergeFindings, sortByLevel, deduplicateWithAI, loadExclusions, applyExclusions, filterFalsePositivesWithAI } from './findings.js';
|
||||
import { reconcileConversations, dropResolvedFindings, addCarriedFindings } from './resolve.js';
|
||||
import { saveFindings, postFindingsReview, formatFindingsStatsLine } from './comments.js';
|
||||
import { cloneRepo, commitAndPush, getRepoState } from './git.js';
|
||||
import { validateJSONArrayFile, ensureJSONArrayFileExists } from './json.js';
|
||||
@@ -43,6 +44,15 @@ async function main() {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
step('Step2', 'PR 對話收斂');
|
||||
let reconcile = { resolvedFindings: [], carriedFindings: [], resolvedCount: 0, unresolvedCount: 0 };
|
||||
try {
|
||||
reconcile = await reconcileConversations();
|
||||
ok(`Step2 完成: resolved=${reconcile.resolvedCount} unresolved=${reconcile.unresolvedCount} 加回=${reconcile.carriedFindings.length}`);
|
||||
} catch (e) {
|
||||
warn(`Step2 對話收斂失敗(繼續執行): ${e.message}`);
|
||||
}
|
||||
|
||||
const { provider, baseURL, model } = getLLMConfig();
|
||||
if (!provider) {
|
||||
error('未設定任何 LLM API Key,請檢查 action inputs');
|
||||
@@ -99,8 +109,13 @@ async function main() {
|
||||
if (repoState) {
|
||||
line(`repo 狀態: branch=${repoState.branch || 'detached'} commit=${repoState.shortSha || 'unknown'} commit_time=${repoState.commitTime || 'unknown'} path=${repoState.repoDir}`);
|
||||
}
|
||||
const oldFindings = loadOldFindings(repoDir || WORKSPACE);
|
||||
let oldFindings = loadOldFindings(repoDir || WORKSPACE);
|
||||
logFindingsStats('Step4 舊 findings 統計', oldFindings);
|
||||
const beforeReconcile = oldFindings.length;
|
||||
oldFindings = dropResolvedFindings(oldFindings, reconcile.resolvedFindings);
|
||||
oldFindings = addCarriedFindings(oldFindings, reconcile.carriedFindings);
|
||||
line(`Step4 對話收斂套用: ${beforeReconcile} -> ${oldFindings.length} 筆(移除已解決 ${reconcile.resolvedFindings.length}、加回未解決 ${reconcile.carriedFindings.length})`);
|
||||
logFindingsStats('Step4 收斂後舊 findings 統計', oldFindings);
|
||||
logFindingsStats('Step4 新 findings 統計', newFindings);
|
||||
const mergedFindings = mergeFindings(oldFindings, newFindings);
|
||||
ok(`Step4 merged findings total=${mergedFindings.length}`);
|
||||
|
||||
Reference in New Issue
Block a user