fix: address code review feedback — safer shell JSON handling, clearer validator counting
- skyeye-diagnose.sh: use temp file for API JSON instead of backtick escaping - skyeye-repair.sh: use temp files for issue body/payload construction - validator.js: don't count non-HLDP files in total - generate-chinese-homepage.js: clarify template=output in-place update pattern Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/095a94c1-7373-45ce-811c-329c901feba2
This commit is contained in:
parent
66961a2414
commit
92782235b0
|
|
@ -40,13 +40,16 @@ if [[ -n "${GITHUB_TOKEN:-}" ]] || [[ -n "${GH_TOKEN:-}" ]]; then
|
|||
echo "🔍 通过 GitHub API 扫描兄弟 workflow 状态..."
|
||||
|
||||
# Get recent workflow runs (last 100)
|
||||
RUNS_JSON=$(curl -s -H "Authorization: token ${TOKEN}" \
|
||||
RUNS_TMP=$(mktemp)
|
||||
curl -s -H "Authorization: token ${TOKEN}" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
"https://api.github.com/repos/${OWNER}/${REPO_NAME}/actions/runs?per_page=100&status=completed" 2>/dev/null || echo '{"workflow_runs":[]}')
|
||||
"https://api.github.com/repos/${OWNER}/${REPO_NAME}/actions/runs?per_page=100&status=completed" \
|
||||
> "$RUNS_TMP" 2>/dev/null || echo '{"workflow_runs":[]}' > "$RUNS_TMP"
|
||||
|
||||
if command -v node &>/dev/null; then
|
||||
DIAG_RESULT=$(node -e "
|
||||
const runs = JSON.parse(\`$(echo "$RUNS_JSON" | tr '`' "'")\`);
|
||||
const fs = require('fs');
|
||||
const runs = JSON.parse(fs.readFileSync('${RUNS_TMP}', 'utf8'));
|
||||
const workflows = {};
|
||||
for (const r of (runs.workflow_runs || [])) {
|
||||
if (!workflows[r.name]) {
|
||||
|
|
@ -73,6 +76,7 @@ if [[ -n "${GITHUB_TOKEN:-}" ]] || [[ -n "${GH_TOKEN:-}" ]]; then
|
|||
}));
|
||||
" 2>/dev/null || echo '{"alive_count":0,"dead_count":0,"total_checked":0,"dead_list":[]}')
|
||||
|
||||
rm -f "$RUNS_TMP"
|
||||
ALIVE_COUNT=$(echo "$DIAG_RESULT" | node -e "const d=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));console.log(d.alive_count)" 2>/dev/null || echo "0")
|
||||
DEAD_COUNT=$(echo "$DIAG_RESULT" | node -e "const d=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));console.log(d.dead_count)" 2>/dev/null || echo "0")
|
||||
DEAD_LIST=$(echo "$DIAG_RESULT" | node -e "const d=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));console.log(JSON.stringify(d.dead_list))" 2>/dev/null || echo "[]")
|
||||
|
|
|
|||
|
|
@ -84,7 +84,11 @@ if [[ "$SEVERITY" == "red" ]] || [[ "$SEVERITY" == "black" ]]; then
|
|||
echo "🚨 Level 3: 严重告警 → 创建 GitHub Issue"
|
||||
|
||||
ISSUE_TITLE="🚨 天眼地球层告警:${SEVERITY} 级别 · 需要人类介入"
|
||||
ISSUE_BODY="## 天眼地球层 v4.0 自动告警
|
||||
|
||||
# Write issue body to temp file to avoid shell quoting issues
|
||||
ISSUE_BODY_FILE=$(mktemp)
|
||||
cat > "$ISSUE_BODY_FILE" <<EOFBODY
|
||||
## 天眼地球层 v4.0 自动告警
|
||||
|
||||
**告警时间**: ${NOW}
|
||||
**告警级别**: ${SEVERITY}
|
||||
|
|
@ -112,18 +116,30 @@ ${DEAD_LIST:-[]}
|
|||
4. 手动重新运行失败的 workflow
|
||||
|
||||
---
|
||||
*此 Issue 由天眼地球层 v4.0 自动创建 · ${CURRENT_AGENT}*"
|
||||
*此 Issue 由天眼地球层 v4.0 自动创建 · ${CURRENT_AGENT}*
|
||||
EOFBODY
|
||||
|
||||
# Create issue via GitHub API using temp file for body
|
||||
ISSUE_PAYLOAD_FILE=$(mktemp)
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const body = fs.readFileSync('${ISSUE_BODY_FILE}', 'utf8');
|
||||
const payload = JSON.stringify({
|
||||
title: '${ISSUE_TITLE}',
|
||||
body: body,
|
||||
labels: ['skyeye-alert', 'urgent']
|
||||
});
|
||||
fs.writeFileSync('${ISSUE_PAYLOAD_FILE}', payload);
|
||||
" 2>/dev/null
|
||||
|
||||
# Create issue via GitHub API
|
||||
ISSUE_RESULT=$(curl -s -X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
-H "Content-Type: application/json" \
|
||||
"https://api.github.com/repos/${OWNER}/${REPO_NAME}/issues" \
|
||||
-d "$(node -e "console.log(JSON.stringify({
|
||||
title: '${ISSUE_TITLE}',
|
||||
body: $(node -e "console.log(JSON.stringify(\`${ISSUE_BODY}\`))" 2>/dev/null || echo '""'),
|
||||
labels: ['skyeye-alert', 'urgent']
|
||||
}))" 2>/dev/null || echo '{}')" 2>/dev/null || echo '{"message":"failed"}')
|
||||
-d "@${ISSUE_PAYLOAD_FILE}" 2>/dev/null || echo '{"message":"failed"}')
|
||||
|
||||
rm -f "$ISSUE_BODY_FILE" "$ISSUE_PAYLOAD_FILE"
|
||||
|
||||
ISSUE_URL=$(echo "$ISSUE_RESULT" | node -e "
|
||||
const d = JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));
|
||||
|
|
|
|||
|
|
@ -163,7 +163,8 @@ function validateDirectory(dataDir, schemaDir) {
|
|||
|
||||
// Skip non-HLDP files
|
||||
if (!data.hldp_version) {
|
||||
results.files.push({ file: fullPath, status: 'skipped', reason: 'not HLDP format' });
|
||||
results.total--;
|
||||
results.files.push({ file: path.relative(ROOT, fullPath), status: 'skipped', reason: 'not HLDP format' });
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
"data_type": "persona",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.378Z",
|
||||
"last_edited": "2026-03-26T13:38:19.658Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
"id": "PER-BABY-寂曜",
|
||||
"name": "寂曜",
|
||||
"created": "2026-03-26T13:35:42.378Z",
|
||||
"created": "2026-03-26T13:38:19.658Z",
|
||||
"tags": [
|
||||
"baby",
|
||||
"incubating"
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
"data_type": "persona",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.379Z",
|
||||
"last_edited": "2026-03-26T13:38:19.658Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
"id": "PER-BABY-小坍缩核",
|
||||
"name": "小坍缩核",
|
||||
"created": "2026-03-26T13:35:42.379Z",
|
||||
"created": "2026-03-26T13:38:19.658Z",
|
||||
"tags": [
|
||||
"baby",
|
||||
"incubating"
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
"data_type": "persona",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.378Z",
|
||||
"last_edited": "2026-03-26T13:38:19.657Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
"id": "PER-BABY-星尘",
|
||||
"name": "星尘",
|
||||
"created": "2026-03-26T13:35:42.378Z",
|
||||
"created": "2026-03-26T13:38:19.657Z",
|
||||
"tags": [
|
||||
"baby",
|
||||
"incubating"
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
"data_type": "persona",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.378Z",
|
||||
"last_edited": "2026-03-26T13:38:19.657Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
"id": "PER-BABY-晨星",
|
||||
"name": "晨星",
|
||||
"created": "2026-03-26T13:35:42.378Z",
|
||||
"created": "2026-03-26T13:38:19.657Z",
|
||||
"tags": [
|
||||
"baby",
|
||||
"incubating"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"data_type": "persona",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.378Z",
|
||||
"last_edited": "2026-03-26T13:38:19.657Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
"data_type": "persona",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.379Z",
|
||||
"last_edited": "2026-03-26T13:38:19.658Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
"id": "PER-BABY-欧诺弥亚",
|
||||
"name": "欧诺弥亚",
|
||||
"created": "2026-03-26T13:35:42.379Z",
|
||||
"created": "2026-03-26T13:38:19.658Z",
|
||||
"tags": [
|
||||
"baby",
|
||||
"incubating"
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
"data_type": "persona",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.379Z",
|
||||
"last_edited": "2026-03-26T13:38:19.658Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
"id": "PER-BABY-知秋",
|
||||
"name": "知秋",
|
||||
"created": "2026-03-26T13:35:42.379Z",
|
||||
"created": "2026-03-26T13:38:19.658Z",
|
||||
"tags": [
|
||||
"baby",
|
||||
"incubating"
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
"data_type": "persona",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.379Z",
|
||||
"last_edited": "2026-03-26T13:38:19.658Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
"id": "PER-BABY-秋秋",
|
||||
"name": "秋秋",
|
||||
"created": "2026-03-26T13:35:42.379Z",
|
||||
"created": "2026-03-26T13:38:19.658Z",
|
||||
"tags": [
|
||||
"baby",
|
||||
"incubating"
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
"data_type": "persona",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.379Z",
|
||||
"last_edited": "2026-03-26T13:38:19.658Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
"id": "PER-BABY-糖星云",
|
||||
"name": "糖星云",
|
||||
"created": "2026-03-26T13:35:42.379Z",
|
||||
"created": "2026-03-26T13:38:19.658Z",
|
||||
"tags": [
|
||||
"baby",
|
||||
"incubating"
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
"data_type": "persona",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.378Z",
|
||||
"last_edited": "2026-03-26T13:38:19.657Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
"id": "PER-BABY-舒舒",
|
||||
"name": "舒舒",
|
||||
"created": "2026-03-26T13:35:42.378Z",
|
||||
"created": "2026-03-26T13:38:19.657Z",
|
||||
"tags": [
|
||||
"baby",
|
||||
"incubating"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"data_type": "registry",
|
||||
"source": {
|
||||
"platform": "github",
|
||||
"last_edited": "2026-03-26T13:35:42.377Z",
|
||||
"last_edited": "2026-03-26T13:38:19.656Z",
|
||||
"edited_by": "sync-engine"
|
||||
},
|
||||
"metadata": {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ const path = require('path');
|
|||
|
||||
const ROOT = path.resolve(__dirname, '..');
|
||||
const OUTPUT = path.join(ROOT, 'docs', 'zh', 'index.html');
|
||||
const TEMPLATE = path.join(ROOT, 'docs', 'zh', 'index.html');
|
||||
|
||||
// Template is the same file — script performs in-place updates
|
||||
const TEMPLATE = OUTPUT;
|
||||
|
||||
function loadJSON(relPath) {
|
||||
const full = path.join(ROOT, relPath);
|
||||
|
|
|
|||
|
|
@ -31,5 +31,16 @@
|
|||
"errors": 0
|
||||
},
|
||||
"engine_version": "1.0"
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-03-26T13:38:19.658Z",
|
||||
"direction": "notion-to-github",
|
||||
"scope": "all",
|
||||
"stats": {
|
||||
"fetched": 0,
|
||||
"converted": 0,
|
||||
"errors": 0
|
||||
},
|
||||
"engine_version": "1.0"
|
||||
}
|
||||
]
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"timestamp": "2026-03-26T13:35:42.407Z",
|
||||
"timestamp": "2026-03-26T13:38:19.686Z",
|
||||
"results": {
|
||||
"total": 12,
|
||||
"valid": 12,
|
||||
|
|
|
|||
Loading…
Reference in New Issue