feat(agent): L3 记忆注入——子任务带父任务拆解意图 + 兄弟状态
- types.TaskContext + Task.context(daemon 装配、不持久化) - store.taskContextOf(taskId):父 plan + 同层兄弟概览(标题/状态/复杂度,排除自身) - orchestrator.claimOne:executor 子任务填充 context 下发(planner 跑在父任务上不需要) - runner.buildPrompt 注入「## 拆解背景」段(顺序:规范→背景→任务内容) - 仅 DB 读,不做 git/RAG 检索(成本控制) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,35 @@ test('L4: globalRules 注入且排在项目规范之前', () => {
|
||||
assert.ok(p.indexOf('GLOBAL_RULE') < p.indexOf('任务内容'));
|
||||
});
|
||||
|
||||
test('L3: context 注入父任务意图 + 兄弟状态,无 context 不注入', () => {
|
||||
const t = fakeTask({
|
||||
context: {
|
||||
parentPlan: '把登录拆成前后端',
|
||||
siblings: [{ title: '前端表单', status: 'done', complexity: 'easy' }],
|
||||
},
|
||||
});
|
||||
const p = buildPrompt(t);
|
||||
assert.ok(p.includes('拆解背景'));
|
||||
assert.ok(p.includes('把登录拆成前后端'));
|
||||
assert.ok(p.includes('前端表单'));
|
||||
assert.ok(p.indexOf('拆解背景') < p.indexOf('任务内容'), '背景在任务内容之前');
|
||||
assert.ok(!buildPrompt(fakeTask()).includes('拆解背景'));
|
||||
});
|
||||
|
||||
test('taskContextOf 取父 plan + 兄弟概览(排除自身)', () => {
|
||||
const s = new Store(':memory:');
|
||||
const pj = s.createProject({ name: 'l3', repoPath: '/tmp/l3-' + Math.random() });
|
||||
const parent = s.createTask({ projectId: pj.id, title: '大', complexity: 'hard' });
|
||||
s.setPlan(parent.id, '拆成 a 和 b');
|
||||
const a = s.createTask({ projectId: pj.id, parentId: parent.id, title: 'a', complexity: 'easy' });
|
||||
s.createTask({ projectId: pj.id, parentId: parent.id, title: 'b', complexity: 'easy' });
|
||||
assert.equal(s.taskContextOf(parent.id), null, '根任务无 parent → null');
|
||||
const ctxA = s.taskContextOf(a.id)!;
|
||||
assert.equal(ctxA.parentPlan, '拆成 a 和 b');
|
||||
assert.deepEqual(ctxA.siblings!.map((x) => x.title), ['b'], '兄弟里不含自身 a');
|
||||
s.close();
|
||||
});
|
||||
|
||||
test('lastRunErrorOf 取最近一次失败 run 的错误(任意 kind)', () => {
|
||||
const s = new Store(':memory:');
|
||||
const p = s.createProject({ name: 'l1', repoPath: '/tmp/l1-' + Math.random() });
|
||||
|
||||
Reference in New Issue
Block a user