From 03870f8822bdbbcbb9472642925fd399158745df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=91=E5=A9=B7=E9=99=88?= Date: Mon, 9 Mar 2026 16:30:00 +0800 Subject: [PATCH] =?UTF-8?q?Step=207:=20=E8=87=AA=E6=A3=80=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=20+=20=E6=AF=8F=E6=97=A5=E8=87=AA=E6=A3=80=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/zhuyuan-daily-selfcheck.yml | 25 ++++---- scripts/selfcheck.js | 57 +++++++++++++++++++ 2 files changed, 69 insertions(+), 13 deletions(-) create mode 100644 scripts/selfcheck.js diff --git a/.github/workflows/zhuyuan-daily-selfcheck.yml b/.github/workflows/zhuyuan-daily-selfcheck.yml index 22e2e3b1..a9036285 100644 --- a/.github/workflows/zhuyuan-daily-selfcheck.yml +++ b/.github/workflows/zhuyuan-daily-selfcheck.yml @@ -1,17 +1,18 @@ -name: 铸渊 · 每日自检与自进化 +name: 铸渊 · 每日自检 on: schedule: - - cron: '0 0 * * *' # UTC 00:00 = 北京时间 08:00 - workflow_dispatch: # 手动触发 + - cron: '0 0 * * *' # UTC 00:00 = 北京时间 08:00 + workflow_dispatch: # 也支持手动触发 jobs: - self-check: - name: 🔍 铸渊每日自检 + selfcheck: + name: 🔍 铸渊自检 runs-on: ubuntu-latest permissions: contents: write - issues: read + issues: write + steps: - uses: actions/checkout@v4 @@ -20,16 +21,14 @@ jobs: with: node-version: '20' - - name: 铸渊自检 - run: node scripts/zhuyuan-daily-selfcheck.js + - name: Run self-check + id: check + run: node scripts/selfcheck.js - - name: 更新图书馆目录 - run: node scripts/generate-repo-map.js - - - name: 提交自检结果 + - name: Commit self-check result run: | git config user.name "铸渊 (ZhùYuān)" git config user.email "zhuyuan@guanghulab.com" - git add .github/persona-brain/ .github/brain/repo-map.json .github/brain/repo-snapshot.md + git add .github/persona-brain/memory.json git diff --cached --quiet || git commit -m "🔍 铸渊每日自检 · $(date +%Y-%m-%d)" git push diff --git a/scripts/selfcheck.js b/scripts/selfcheck.js new file mode 100644 index 00000000..d6f911e3 --- /dev/null +++ b/scripts/selfcheck.js @@ -0,0 +1,57 @@ +const fs = require('fs'); +const path = require('path'); + +const BRAIN = '.github/persona-brain'; +const requiredFiles = [ + 'identity.md', + 'memory.json', + 'routing-map.json', + 'responsibility.md', + 'decision-log.md', + 'growth-journal.md' +]; + +console.log('🔍 铸渊每日自检开始\n'); + +// 1. 大脑完整性检查 +let brainOK = true; +requiredFiles.forEach(f => { + const exists = fs.existsSync(path.join(BRAIN, f)); + console.log((exists ? '✅' : '❌') + ' ' + f); + if (!exists) brainOK = false; +}); + +// 2. Schema 覆盖率 +let schemaCount = 0; +const SCHEMA_DIR = 'src/schemas/hli'; +const domains = ['auth', 'persona', 'user', 'ticket', 'dialogue', 'storage', 'dashboard']; + +domains.forEach(d => { + const sp = path.join(SCHEMA_DIR, d); + if (fs.existsSync(sp)) { + schemaCount += fs.readdirSync(sp).filter(f => f.endsWith('.schema.json')).length; + } +}); +console.log(`\n📊 HLI 覆盖率: ${schemaCount}/17`); + +// 3. 未处理广播检查 +const broadcastDir = '.github/broadcasts'; +let pendingBroadcasts = 0; +if (fs.existsSync(broadcastDir)) { + pendingBroadcasts = fs.readdirSync(broadcastDir).filter(f => + !fs.statSync(path.join(broadcastDir, f)).isDirectory() + ).length; +} +console.log(`📬 待处理广播: ${pendingBroadcasts}`); + +// 4. 更新 memory.json +let memory = JSON.parse(fs.readFileSync(path.join(BRAIN, 'memory.json'), 'utf8')); +memory.daily_selfcheck = { + last_run: new Date().toISOString(), + brain_integrity: brainOK ? 'ok' : 'missing_files', + schema_coverage: schemaCount + '/17', + pending_broadcasts: pendingBroadcasts +}; +fs.writeFileSync(path.join(BRAIN, 'memory.json'), JSON.stringify(memory, null, 2)); + +console.log('\n' + (brainOK ? '✅' : '⚠️') + ' 铸渊自检完成');