feat: 同步引擎+Agent配置+依赖自动落位+看板大改(预览/md渲染/筛选/徽章组)
后端: - src/sync/todo-sync.ts: todo.json 单向同步引擎(导入=首次同步,幂等,source_ref 映射, subs 复杂度修正为 easy,旧侧 done 历史事实优先 forceDone) - 依赖自动落位:ready 意图按 deps 落位 blocked,依赖全 done 自动放行, daemon 启动 reconcileDeps 对账,手动绕过会弹回 - 新 API: PATCH projects/:id(autonomy/concurrency)、POST :id/sync、GET /api/agents、 PATCH tasks/:id(title/priority/complexity 重置) - daemon 定时同步(MAESTRO_SYNC_INTERVAL 默认 300s) + project.synced 事件 - priority 语义翻转: P0 最高/P1 默认/P2 最低,取值限 0..2,排序/映射/MCP/CLI 全跟进 - 静态服务发 no-cache 头(修浏览器吃旧 CSS/JS) - schema 迁移: tasks.source_ref / projects.last_sync_at(ensureColumn 平滑升级旧库) 看板: - 全屏预览模式(94vh 读完整方案+就地裁决,Esc/遮罩/裁决自动关闭) - 产出 markdown 渲染为 HTML(零依赖渲染器,转义优先) - 任务树筛选(复杂度/状态分组/关键字)+ 顶栏徽章组(待审批/可执行/执行中,hover 展开) - 依赖可视化:详情 DEPS 区块 + 行内⛓等依赖 + 锚点跳转定位 - 按钮收敛:提交评审/编辑产出移除(CC 经 MCP 操作),界面只留用户动作 - Agent 执行面板 + 项目配置(并发/工作模式)+ 同步按钮 测试:21 个全过(新增 sync 幂等/迁移/patch/依赖落位/对账幂等) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -126,3 +126,41 @@ test('事件订阅:状态变更广播', () => {
|
||||
assert.ok(got.includes('status.changed'));
|
||||
s.close();
|
||||
});
|
||||
|
||||
test('依赖自动落位:建任务带未完成依赖 → blocked;依赖 done → 自动放行 ready', () => {
|
||||
const s = freshStore();
|
||||
const p = s.createProject({ name: 'ab', repoPath: '/tmp/ab-' + Math.random() });
|
||||
const a = s.createTask({ projectId: p.id, title: 'A', complexity: 'easy' });
|
||||
const b = s.createTask({ projectId: p.id, title: 'B', complexity: 'easy', deps: [a.id] });
|
||||
assert.equal(b.status, 'blocked'); // 建即落位 blocked,而非假 ready
|
||||
|
||||
// 手动把 blocked 拉成 ready 也会被按依赖弹回(仍 blocked)
|
||||
assert.equal(s.transition(b.id, 'ready').status, 'blocked');
|
||||
|
||||
// A 走完整闭环到 done → B 自动放行
|
||||
const evts = [];
|
||||
s.subscribe((e) => evts.push(e));
|
||||
s.transition(a.id, 'queued');
|
||||
s.transition(a.id, 'executing');
|
||||
s.transition(a.id, 'exec_review');
|
||||
s.decide(a.id, 'accept', 'user');
|
||||
assert.equal(s.getTask(b.id).status, 'ready'); // 自动 blocked→ready
|
||||
const auto = evts.find((e) => e.taskId === b.id && e.payload.auto === 'deps-met');
|
||||
assert.ok(auto, '应有 deps-met 自动放行事件');
|
||||
s.close();
|
||||
});
|
||||
|
||||
test('reconcileDeps:存量 ready 但依赖未满足 → 纠正为 blocked(幂等)', () => {
|
||||
const s = freshStore();
|
||||
const p = s.createProject({ name: 'rc', repoPath: '/tmp/rc-' + Math.random() });
|
||||
const a = s.createTask({ projectId: p.id, title: 'A', complexity: 'easy' });
|
||||
const b = s.createTask({ projectId: p.id, title: 'B', complexity: 'easy', deps: [a.id] });
|
||||
// 模拟旧库脏数据:B 被直接写成 ready
|
||||
s.db.prepare(`UPDATE tasks SET status = 'ready' WHERE id = ?`).run(b.id);
|
||||
const r1 = s.reconcileDeps(p.id);
|
||||
assert.equal(r1.blocked, 1);
|
||||
assert.equal(s.getTask(b.id).status, 'blocked');
|
||||
const r2 = s.reconcileDeps(p.id); // 幂等
|
||||
assert.equal(r2.blocked + r2.released, 0);
|
||||
s.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user