初始提交:ai-review 项目当前版本(含赛道一/二提交规范修订与时间节点文档)
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
const BASE = 'http://localhost:3002';
|
||||
const PID = 'b1b5884e-ba85-4d8f-9a92-e524603587a0';
|
||||
|
||||
async function main() {
|
||||
// Login
|
||||
const login = await fetch(`${BASE}/api/auth/login`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ password: '620f4c96' })
|
||||
});
|
||||
const { token } = await login.json();
|
||||
const auth = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` };
|
||||
|
||||
// Create entry
|
||||
const create = await fetch(`${BASE}/api/projects/${PID}/entries`, {
|
||||
method: 'POST',
|
||||
headers: auth,
|
||||
body: JSON.stringify({
|
||||
title: 'cobol-java验证-10维度',
|
||||
repo_url: 'https://gittea.dev/hangshuo652/jcl-cobol-git',
|
||||
category_tag: '赛道一',
|
||||
participant: 'hangshuo'
|
||||
})
|
||||
});
|
||||
const entry = await create.json();
|
||||
console.log('ENTRY:', JSON.stringify({ id: entry.id, status: entry.status, pass_line: entry.pass_line }));
|
||||
|
||||
// Start review
|
||||
const start = await fetch(`${BASE}/api/projects/${PID}/entries/${entry.id}/start`, {
|
||||
method: 'POST', headers: auth
|
||||
});
|
||||
console.log('START:', await start.json());
|
||||
|
||||
// Poll
|
||||
for (let i = 0; i < 12; i++) {
|
||||
await new Promise(r => setTimeout(r, 15000));
|
||||
const res = await fetch(`${BASE}/api/projects/${PID}/entries/${entry.id}`, { headers: auth });
|
||||
const data = await res.json();
|
||||
const logs = JSON.parse(data.progress_log || '[]');
|
||||
console.log(`POLL_${i}: STATUS=${data.status} RAW=${data.raw_score} FINAL=${data.final_score} LOGS=${logs.length}`);
|
||||
if (data.status === 'review_done') {
|
||||
const report = JSON.parse(data.ai_report);
|
||||
console.log(`SCORE: ${report.pct} (${report.totalScore}/${report.maxTotal})`);
|
||||
report.dimensions.forEach(d => console.log(` ${d.name}: ${d.score}/${d.maxScore}`));
|
||||
logs.forEach(l => console.log(` LOG: ${l.status || ''} ${l.msg?.slice(0, 60)}`));
|
||||
break;
|
||||
}
|
||||
if (data.status?.includes('_fail') || data.status === 'failed') {
|
||||
console.log('FAILED:', data.progress_log);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
Reference in New Issue
Block a user