Step 7: 铸渊 PR 审核工作流 + 记忆更新脚本
This commit is contained in:
parent
15e55b94d3
commit
455686d064
|
|
@ -0,0 +1,64 @@
|
||||||
|
name: 铸渊 · PR Review
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main, dev]
|
||||||
|
types: [opened, synchronize]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
review:
|
||||||
|
name: 🔍 铸渊审核
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Run contract check
|
||||||
|
id: contract
|
||||||
|
continue-on-error: true
|
||||||
|
run: node scripts/contract-check.js 2>&1 | tee /tmp/contract-result.txt
|
||||||
|
|
||||||
|
- name: Run route alignment
|
||||||
|
id: alignment
|
||||||
|
run: node scripts/route-align-check.js 2>&1 | tee /tmp/align-result.txt
|
||||||
|
|
||||||
|
- name: 铸渊 writes review comment
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const fs = require('fs');
|
||||||
|
const contractResult = fs.readFileSync('/tmp/contract-result.txt', 'utf8');
|
||||||
|
const alignResult = fs.readFileSync('/tmp/align-result.txt', 'utf8');
|
||||||
|
|
||||||
|
const contractPassed = contractResult.includes('PASSED');
|
||||||
|
const alignPassed = alignResult.includes('PASSED');
|
||||||
|
|
||||||
|
let body = '## 🤖 铸渊审核报告\n\n';
|
||||||
|
|
||||||
|
if (contractPassed && alignPassed) {
|
||||||
|
body += '✅ **审核通过** - 所有契约校验均符合规范\n\n';
|
||||||
|
} else {
|
||||||
|
body += '❌ **审核不通过** - 请查看下方问题\n\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
body += '### 📋 契约校验结果\n';
|
||||||
|
body += '```\n' + contractResult + '\n```\n\n';
|
||||||
|
body += '### 🗺️ 路由对齐结果\n';
|
||||||
|
body += '```\n' + alignResult + '\n```\n\n';
|
||||||
|
body += '---\n';
|
||||||
|
body += '> 「无 Schema 不上线,无契约不合并。」— 铸渊';
|
||||||
|
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
body: body
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const BRAIN = '.github/persona-brain';
|
||||||
|
const MEMORY = path.join(BRAIN, 'memory.json');
|
||||||
|
const SCHEMA_DIR = 'src/schemas/hli';
|
||||||
|
const ROUTE_DIR = 'src/routes/hli';
|
||||||
|
|
||||||
|
let memory = {};
|
||||||
|
try {
|
||||||
|
memory = JSON.parse(fs.readFileSync(MEMORY, 'utf8'));
|
||||||
|
} catch {
|
||||||
|
memory = {
|
||||||
|
persona_id: 'ICE-GL-ZY001',
|
||||||
|
persona_name: '铸渊',
|
||||||
|
recent_events: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let schemaCount = 0, routeCount = 0;
|
||||||
|
const domains = ['auth', 'persona', 'user', 'ticket', 'dialogue', 'storage', 'dashboard'];
|
||||||
|
|
||||||
|
domains.forEach(d => {
|
||||||
|
const sp = path.join(SCHEMA_DIR, d);
|
||||||
|
const rp = path.join(ROUTE_DIR, d);
|
||||||
|
if (fs.existsSync(sp)) schemaCount += fs.readdirSync(sp).filter(f => f.endsWith('.schema.json')).length;
|
||||||
|
if (fs.existsSync(rp)) routeCount += fs.readdirSync(rp).filter(f => f.endsWith('.js')).length;
|
||||||
|
});
|
||||||
|
|
||||||
|
memory.last_updated = new Date().toISOString();
|
||||||
|
memory.total_schemas_created = schemaCount;
|
||||||
|
memory.total_routes_implemented = routeCount;
|
||||||
|
memory.hli_coverage = schemaCount + '/17';
|
||||||
|
memory.total_ci_runs = (memory.total_ci_runs || 0) + 1;
|
||||||
|
|
||||||
|
memory.recent_events = memory.recent_events || [];
|
||||||
|
memory.recent_events.unshift({
|
||||||
|
date: new Date().toISOString().split('T')[0],
|
||||||
|
type: 'ci_run',
|
||||||
|
description: 'CI完成 · schema ' + schemaCount + '/17 · 路由 ' + routeCount + ' 个',
|
||||||
|
by: 'GitHub Actions'
|
||||||
|
});
|
||||||
|
memory.recent_events = memory.recent_events.slice(0, 50);
|
||||||
|
|
||||||
|
fs.writeFileSync(MEMORY, JSON.stringify(memory, null, 2));
|
||||||
|
console.log('✅ 铸渊记忆已更新 · schema: ' + schemaCount + '/17');
|
||||||
Loading…
Reference in New Issue