diff --git a/.github/workflows/zhuyuan-skyeye.yml b/.github/workflows/zhuyuan-skyeye.yml index 87b60ca8..41c59e40 100644 --- a/.github/workflows/zhuyuan-skyeye.yml +++ b/.github/workflows/zhuyuan-skyeye.yml @@ -53,7 +53,7 @@ jobs: mkdir -p /tmp/skyeye node scripts/skyeye/scan-workflows.js > /tmp/skyeye/workflow-health.json gh run list --limit 50 --json name,status,conclusion,createdAt,updatedAt \ - > /tmp/skyeye/recent-runs.json || echo "[]" > /tmp/skyeye/recent-runs.json + > /tmp/skyeye/recent-runs.json || { echo "⚠️ gh run list 失败,使用空列表" && echo "[]" > /tmp/skyeye/recent-runs.json; } FAILED_COUNT=$(cat /tmp/skyeye/recent-runs.json | \ python3 -c "import sys,json; runs=json.load(sys.stdin); print(sum(1 for r in runs if r.get('conclusion')=='failure'))" 2>/dev/null || echo "0") echo "failed_count=$FAILED_COUNT" >> $GITHUB_OUTPUT diff --git a/scripts/gate-guard.js b/scripts/gate-guard.js index 8891aa7a..f4f802ac 100644 --- a/scripts/gate-guard.js +++ b/scripts/gate-guard.js @@ -185,8 +185,10 @@ function main() { if (disallowedFiles.length > 0 && allowedFiles.length > 0) { // 部分文件越权,部分合法 → 回退整个 commit(不做部分修复,避免复杂性) - const msg = `⚠️ 部分路径越权 · 推送者: ${actor} · ${developer.name}(${developer.devId})\n\n` + - `允许路径: ${developer.allowed_paths.join(', ')}\n\n` + + const devName = developer ? `${developer.name}(${developer.devId})` : `未注册开发者`; + const devPaths = developer && developer.allowed_paths ? developer.allowed_paths.join(', ') : '无'; + const msg = `⚠️ 部分路径越权 · 推送者: ${actor} · ${devName}\n\n` + + `允许路径: ${devPaths}\n\n` + `✅ 合法文件:\n` + allowedFiles.map(f => `- \`${f}\``).join('\n') + '\n\n' + `❌ 越权文件:\n` + disallowedFiles.map(f => `- \`${f}\``).join('\n') + `\n\n该 commit 已被自动回退。请将越权文件移除后重新提交。`; diff --git a/scripts/skyeye/report-generator.js b/scripts/skyeye/report-generator.js index 3f9cf27c..80df3a23 100644 --- a/scripts/skyeye/report-generator.js +++ b/scripts/skyeye/report-generator.js @@ -104,16 +104,19 @@ function generateReport() { auto_fixed: repairResult ? repairResult.total_repaired : 0, needs_human: diagnosis ? diagnosis.needs_human : 0, watching: diagnosis ? diagnosis.watch_list : 0, - issues: diagnosis ? (diagnosis.issues || []).map(i => ({ - id: i.id, - symptom: i.symptom, - root_cause: i.root_cause, - impact: i.impact, - fix_applied: i.fixable ? i.fix_plan : null, - verified: repairResult - ? (repairResult.repairs || []).find(r => r.issue_id === i.id)?.verified || false - : false - })) : [] + issues: diagnosis ? (diagnosis.issues || []).map(i => { + const repairEntry = repairResult + ? (repairResult.repairs || []).find(r => r.issue_id === i.id) + : null; + return { + id: i.id, + symptom: i.symptom, + root_cause: i.root_cause, + impact: i.impact, + fix_applied: i.fixable ? i.fix_plan : null, + verified: repairEntry ? repairEntry.verified : false + }; + }) : [] }, repairs_applied: repairResult diff --git a/scripts/skyeye/scan-workflows.js b/scripts/skyeye/scan-workflows.js index 06e063ff..9d85a97d 100644 --- a/scripts/skyeye/scan-workflows.js +++ b/scripts/skyeye/scan-workflows.js @@ -27,7 +27,7 @@ function checkYamlSyntax(filePath) { const content = fs.readFileSync(filePath, 'utf8'); // Basic checks: not empty, has 'name:', has 'on:', has 'jobs:' const hasName = /^name\s*:/m.test(content); - const hasOn = /^on\s*:/m.test(content) || /^on:/m.test(content) || /^"on"\s*:/m.test(content) || /^'on'\s*:/m.test(content); + const hasOn = /^on\s*:/m.test(content) || /^"on"\s*:/m.test(content) || /^'on'\s*:/m.test(content); const hasJobs = /^jobs\s*:/m.test(content); const issues = []; diff --git a/scripts/skyeye/sync-to-notion.js b/scripts/skyeye/sync-to-notion.js index 12cdd0b5..53695a31 100644 --- a/scripts/skyeye/sync-to-notion.js +++ b/scripts/skyeye/sync-to-notion.js @@ -55,7 +55,7 @@ function notionRequest(apiPath, body) { if (res.statusCode >= 200 && res.statusCode < 300) { resolve({ statusCode: res.statusCode, body: data }); } else { - reject(new Error(`Notion API ${res.statusCode}: ${data.substring(0, 200)}`)); + reject(new Error(`Notion API ${res.statusCode}: ${data.length > 200 ? data.substring(0, 200) + '...' : data}`)); } }); });