🦅 天眼系统代码审查修复 · 简化正则 + 错误提示优化 + 空值安全 + 降级日志增强

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-16 05:40:24 +00:00
parent 9d3fc45205
commit e9fd2ec4f4
5 changed files with 20 additions and 15 deletions

View File

@ -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

View File

@ -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 已被自动回退。请将越权文件移除后重新提交。`;

View File

@ -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

View File

@ -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 = [];

View File

@ -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}`));
}
});
});