docs(workflow 階段): 將前置驗證改為 Step2

This commit is contained in:
2026-06-22 10:20:52 +00:00
parent 6256576603
commit 4dc50941b0
6 changed files with 28 additions and 28 deletions
+12 -12
View File
@@ -71,7 +71,7 @@ async function main() {
warn(`comment 發布失敗(繼續執行): ${e.message}`);
}
step('Step2', 'Findings 產生');
step('Step3', 'Findings 產生');
const results = await Promise.allSettled(roles.map(role => analyzeWithRole(role, diff)));
const newFindings = [];
for (let i = 0; i < results.length; i++) {
@@ -81,9 +81,9 @@ async function main() {
warn(`[${roles[i].name}] 分析失敗(跳過): ${results[i].reason?.message}`);
}
}
ok(`Step2 完成: 新 findings 總計 ${newFindings.length}`);
ok(`Step3 完成: 新 findings 總計 ${newFindings.length}`);
step('Step3', 'Findings 合併與語意去重');
step('Step4', 'Findings 合併與語意去重');
let repoDir;
try {
repoDir = cloneRepo(WORKSPACE);
@@ -96,28 +96,28 @@ async function main() {
}
const oldFindings = loadOldFindings(repoDir || WORKSPACE);
const mergedFindings = mergeFindings(oldFindings, newFindings);
ok(`Step3 merged findings total=${mergedFindings.length}`);
ok(`Step4 merged findings total=${mergedFindings.length}`);
const deduped = await deduplicateWithAI(mergedFindings);
const sorted = sortByLevel(deduped);
ok(`Step3 去重完成: ${mergedFindings.length} -> ${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})`);
ok(`Step4 去重完成: ${mergedFindings.length} -> ${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})`);
step('Step4', 'AI 排除問題過濾');
step('Step5', 'AI 排除問題過濾');
const exclusions = loadExclusions(repoDir || WORKSPACE, repoState, WORKSPACE);
const ruleFiltered = applyExclusions(sorted, exclusions);
const filtered = await filterFalsePositivesWithAI(ruleFiltered, exclusions);
ok(`Step4 完成: findings total=${filtered.length}`);
ok(`Step5 完成: findings total=${filtered.length}`);
step('Step5', 'Findings 寫入與 Review 發布');
step('Step6', 'Findings 寫入與 Review 發布');
const reviewDir = repoDir || WORKSPACE;
saveFindings(WORKSPACE, filtered, reviewDir);
try {
await postFindingsReview(filtered);
ok('Step5 完成');
ok('Step6 完成');
} catch (e) {
warn(`review 發布失敗(繼續執行): ${e.message}`);
}
step('Step6', 'JSON 格式驗證');
step('Step7', 'JSON 格式驗證');
const missingPaths = [];
for (const relPath of [FINDINGS_PATH, EXCLUSIONS_PATH]) {
const fullPath = path.join(reviewDir, relPath);
@@ -133,12 +133,12 @@ async function main() {
ensureJSONArrayFileExists(fullPath, relPath);
}
step('Step7', '記憶區 Commit/Push');
step('Step8', '記憶區 Commit/Push');
const reviewOutcome = filtered.some(f => f.level === 'critical') ? 'failure' : 'success';
line(`review outcome=${reviewOutcome}`);
await commitAndPush(WORKSPACE, repoDir || WORKSPACE, undefined, undefined, reviewOutcome);
step('Step8', '嚴重問題檢查');
step('Step9', '嚴重問題檢查');
const criticalCount = filtered.filter(f => f.level === 'critical').length;
if (criticalCount > 0) {
error(`發現 ${criticalCount} 個嚴重問題,workflow 結束(exit 1`);