feat: 階段二 - Findings 產生與合併
- app/findings.js: 各角色分析 diff、讀取舊 findings、合併去重、等級排序 - app/main.js: 實作 Step2/Step3,log findings 統計
This commit is contained in:
+21
-4
@@ -1,6 +1,9 @@
|
||||
import { GITEA_REPOSITORY, PR_NUMBER, PR_HEAD_BRANCH, PR_BASE_BRANCH, getLLMConfig } from './config.js';
|
||||
import { loadRoles, getRoleIntro } from './roles.js';
|
||||
import { getPRDiff, postComment } from './gitea.js';
|
||||
import { analyzeWithRole, loadOldFindings, mergeFindings, sortByLevel } from './findings.js';
|
||||
|
||||
const WORKSPACE = process.env.GITHUB_WORKSPACE || '/workspace';
|
||||
|
||||
async function main() {
|
||||
console.log('='.repeat(60));
|
||||
@@ -46,11 +49,25 @@ async function main() {
|
||||
console.log(` ⚠️ comment 發布失敗(繼續執行): ${e.message}`);
|
||||
}
|
||||
|
||||
console.log('\n📊 Step2: Findings 產生(待實作)');
|
||||
console.log(' [stub] 各角色分析 diff...');
|
||||
// Step2: 各角色分析 diff 產生新 findings
|
||||
console.log('\n📊 Step2: Findings 產生');
|
||||
const newFindings = [];
|
||||
for (const role of roles) {
|
||||
try {
|
||||
const found = await analyzeWithRole(role, diff);
|
||||
newFindings.push(...found);
|
||||
} catch (e) {
|
||||
console.log(` ⚠️ [${role.name}] 分析失敗(跳過): ${e.message}`);
|
||||
}
|
||||
}
|
||||
console.log(` Step2 完成: 新 findings 總計 ${newFindings.length} 筆`);
|
||||
|
||||
console.log('\n🔀 Step3: Findings 合併與去重(待實作)');
|
||||
console.log(' [stub] 合併新舊 findings...');
|
||||
// Step3: 讀取舊 findings,合併去重
|
||||
console.log('\n🔀 Step3: Findings 合併');
|
||||
const oldFindings = loadOldFindings(WORKSPACE);
|
||||
const mergedFindings = mergeFindings(oldFindings, newFindings);
|
||||
const sorted = sortByLevel(mergedFindings);
|
||||
console.log(` Step3 merged findings total=${sorted.length} (critical=${sorted.filter(f=>f.level==='critical').length} warning=${sorted.filter(f=>f.level==='warning').length} info=${sorted.filter(f=>f.level==='info').length})`);
|
||||
|
||||
console.log('\n📝 Step4: Findings 寫入與 Comment 發布(待實作)');
|
||||
console.log(' [stub] 寫入 findings.json,發布 comment...');
|
||||
|
||||
Reference in New Issue
Block a user