# ━━━ 铸渊自动更新 README 仪表盘 ━━━ # 每日自动更新:仪表盘 + 共生动态 + 联邦状态 # Agent: AG-ZY-087 · update-readme.yml # Parent: SYS-GLW-0001 · Owner: ICE-0002∞ name: 📊 README 仪表盘自动更新 on: schedule: # 每日 08:00 CST = 00:00 UTC - cron: '0 0 * * *' # 每日 20:00 CST = 12:00 UTC - cron: '0 12 * * *' workflow_dispatch: permissions: contents: write jobs: update-dashboard: runs-on: ubuntu-latest steps: - name: 📥 Checkout uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - name: 🟢 Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: 📊 Update Dashboard Data run: | echo "📊 开始更新 README 仪表盘..." # ── 收集实时统计 ── WORKFLOW_COUNT=$(find .github/workflows -name '*.yml' -o -name '*.yaml' | wc -l) AGENT_COUNT=$(node -e "const d=require('./.github/persona-brain/agent-registry.json'); console.log(d.agents ? d.agents.length : 0)") PERSONA_COUNT=$(node -e "const d=require('./.github/persona-brain/persona-registry.json'); console.log(d.personas ? d.personas.length : 0)") GUARD_COUNT=$(find skyeye/guards -name '*.json' ! -name 'template*' 2>/dev/null | wc -l) MODULE_COUNT=$(find . -maxdepth 1 -type d -name 'm[0-9]*' | wc -l) BUFFER_COUNT=$(find buffer/inbox -type f ! -name '.gitkeep' 2>/dev/null | wc -l) echo "Workflows: $WORKFLOW_COUNT" echo "Agents: $AGENT_COUNT" echo "Personas: $PERSONA_COUNT" echo "Guards: $GUARD_COUNT" echo "Modules: $MODULE_COUNT" echo "Buffer: $BUFFER_COUNT" # ── 更新 data/system-health.json ── NOW=$(date -u -d '+8 hours' '+%Y-%m-%dT%H:%M:%S+08:00') node -e " const fs = require('fs'); const health = JSON.parse(fs.readFileSync('data/system-health.json', 'utf8')); health.last_updated = '$NOW'; health.metrics.workflows.total = $WORKFLOW_COUNT; health.metrics.ai_personas.total = $PERSONA_COUNT; health.metrics.guards.total = $GUARD_COUNT; health.metrics.guards.active = $GUARD_COUNT; health.metrics.modules.total = $MODULE_COUNT; health.metrics.buffer_pending = $BUFFER_COUNT; fs.writeFileSync('data/system-health.json', JSON.stringify(health, null, 2) + '\n'); console.log('✅ system-health.json 已更新'); " # ── 更新 README 中的仪表盘数字 ── # 更新 shields.io 徽章数字 sed -i "s|Workflows-[0-9]*-|Workflows-${WORKFLOW_COUNT}-|g" README.md sed -i "s|Agents-[0-9]*-|Agents-${AGENT_COUNT}-|g" README.md sed -i "s|Personas-[0-9]*-|Personas-${PERSONA_COUNT}-|g" README.md sed -i "s|Modules-[0-9]*-|Modules-${MODULE_COUNT}-|g" README.md echo "✅ README 徽章数字已更新" - name: 🌍 Update Federation Status run: | echo "🌍 更新联邦状态..." node -e " const fs = require('fs'); const path = require('path'); // 读取 spoke-status 目录 const spokeDir = 'spoke-status'; const files = fs.readdirSync(spokeDir).filter(f => f.startsWith('DEV-') && f.endsWith('.json')); const now = Date.now(); const DAY_MS = 24 * 60 * 60 * 1000; for (const file of files) { try { const data = JSON.parse(fs.readFileSync(path.join(spokeDir, file), 'utf8')); if (data.last_checkin) { const checkinTime = new Date(data.last_checkin).getTime(); const diff = now - checkinTime; if (diff > 72 * DAY_MS) { data.status = 'alert_72h'; } else if (diff > DAY_MS) { data.status = 'warning_24h'; } else { data.status = 'active'; } fs.writeFileSync(path.join(spokeDir, file), JSON.stringify(data, null, 2) + '\n'); } } catch (e) { console.log('⚠️ 跳过 ' + file + ': ' + e.message); } } console.log('✅ 联邦状态检查完成'); " - name: 📤 Commit & Push run: | git config user.name "铸渊 (ZhuYuan Bot)" git config user.email "github-actions[bot]@users.noreply.github.com" git add data/system-health.json README.md spoke-status/ if git diff --cached --quiet; then echo "📋 无变更,跳过提交" else git commit -m "📊 铸渊: 仪表盘自动更新 $(date -u -d '+8 hours' '+%Y-%m-%d %H:%M') CST [skip ci]" git push echo "✅ 已推送更新" fi