f18db021c3
调度: - model/scoring.ts: score = 自身分(P0=3/P1=2/P2=1) + 已完成依赖分(链条惯性) + 等待解锁的 blocked 任务分(解锁加权),编排器与 nextExecutable 同一打分 - createTask 校验 deps 存在且同项目(依赖图天然无环) - daemon 重启中断自愈: executing 任务标 failed run 后重新入队(reconcileInterrupted) 执行管线: - executor/cc.ts: 公共 headless CC 执行器(转录/超时/模型回退重试) - executor/reviewer.ts: 执行后自动复审(只读 CC 审 diff),固定模板 summary (做了什么/怎么做/测试/CodeReview/安全Review/结论) + VERDICT 解析 - executor/models.ts: 按复杂度选模型(easy→sonnet/medium→opus/hard→fable5), env 可覆盖、project.model 最优先、不可用自动回退链 - runner: 测试/构建命令白名单(npm/go/shellcheck/make/pytest),prompt 要求实跑测试 - TaskResult 加 summary/verdict; RunKind 加 reviewer - 容器收口: 已拆解 Hard 子任务全 done → 容器自动 done(afterDone 逐级向上) 看板: - 五徽章组(待审批/待执行/执行中/被阻塞/总量,hover 展开,均不含已完成) - 归档区: 深度1整树完成沉底,时间倒序分页(10/20/50/100 chip 选择) - 归档详情对话框: 全属性/执行历史与时长/审批记录/状态流转时间线(含相关人或事) - Agent 面板显示调度模式 + 各复杂度实际模型 - 结果闸展示复审 summary + 建议通过/拒绝徽章 - 筛选修复(组选与单选分离、已拆解移出进行中)、同步按钮收进配置面板、 保存配置自动收起、预览全宽、被依赖阻塞→被阻塞 - API: GET /api/tasks/:id/events(任务级事件时间线)、/api/agents 带 scheduling/models 测试: 49/49(新增 scoring/复审/模型/容器收口/deps 校验/中断恢复) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
58 lines
2.8 KiB
TypeScript
58 lines
2.8 KiB
TypeScript
import { test } from 'node:test';
|
||
import assert from 'node:assert/strict';
|
||
import { parseVerdict, buildReviewPrompt } from '../src/executor/reviewer.js';
|
||
import type { Project, Task } from '../src/model/types.js';
|
||
|
||
test('parseVerdict:approve', () => {
|
||
const { summary, verdict } = parseVerdict('## 做了什么\n改了 README\n\n## 结论\n建议通过\nVERDICT: approve');
|
||
assert.equal(verdict, 'approve');
|
||
assert.equal(summary, '## 做了什么\n改了 README\n\n## 结论\n建议通过'); // VERDICT 行已剔除
|
||
});
|
||
|
||
test('parseVerdict:reject(大小写/前后空白宽容)', () => {
|
||
const { summary, verdict } = parseVerdict('问题很多\n verdict: REJECT \n');
|
||
assert.equal(verdict, 'reject');
|
||
assert.equal(summary, '问题很多');
|
||
});
|
||
|
||
test('parseVerdict:解析不到 = null,summary 原样保留', () => {
|
||
const { summary, verdict } = parseVerdict('## 结论\n建议通过,但忘了写 VERDICT 行');
|
||
assert.equal(verdict, null);
|
||
assert.equal(summary, '## 结论\n建议通过,但忘了写 VERDICT 行');
|
||
});
|
||
|
||
test('parseVerdict:多个 VERDICT 行取最后一个,全部从 summary 剔除', () => {
|
||
const { summary, verdict } = parseVerdict('VERDICT: approve\n复查后改判\nVERDICT: reject');
|
||
assert.equal(verdict, 'reject');
|
||
assert.equal(summary, '复查后改判');
|
||
});
|
||
|
||
test('parseVerdict:VERDICT 行带多余内容不算(如模板原文 approve|reject)', () => {
|
||
const { verdict } = parseVerdict('VERDICT: approve|reject');
|
||
assert.equal(verdict, null);
|
||
});
|
||
|
||
test('buildReviewPrompt:含任务说明、执行者自述、diff 指令与固定模板', () => {
|
||
const task = { id: 'task_1', title: '修复登录', operations: '改 auth.ts', spec: null, plan: null } as Task;
|
||
const project = { defaultBranch: 'main' } as Project;
|
||
const wt = { dir: '/tmp/wt', branch: 'maestro/task_1' };
|
||
const prompt = buildReviewPrompt(task, project, wt, '我改了 auth.ts 并加了测试');
|
||
|
||
assert.match(prompt, /修复登录/);
|
||
assert.match(prompt, /改 auth\.ts/);
|
||
assert.match(prompt, /我改了 auth\.ts 并加了测试/);
|
||
assert.match(prompt, /git diff main\.\.\.maestro\/task_1/);
|
||
for (const section of ['## 做了什么', '## 怎么做的', '## 测试情况', '## Code Review', '## 安全 Review', '## 结论']) {
|
||
assert.ok(prompt.includes(section), `模板缺少 ${section}`);
|
||
}
|
||
assert.match(prompt, /VERDICT: approve\|reject/);
|
||
assert.match(prompt, /只读权限/);
|
||
});
|
||
|
||
test('buildReviewPrompt:执行者无自述时给占位说明', () => {
|
||
const task = { id: 'task_2', title: 't', operations: null, spec: null, plan: null } as Task;
|
||
const project = { defaultBranch: 'main' } as Project;
|
||
const prompt = buildReviewPrompt(task, project, { dir: '/x', branch: 'maestro/task_2' }, '');
|
||
assert.match(prompt, /执行者未留下自述/);
|
||
});
|