Step 7: 自检脚本 + 每日自检工作流
This commit is contained in:
parent
0105815fb6
commit
03870f8822
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 ? '✅' : '⚠️') + ' 铸渊自检完成');
|
||||
Loading…
Reference in New Issue