Implement Experience V1 reflect, retrieval boost, and product metrics.

Add rule-based reflect() to aggregate task outcomes, environment-aware search scoring, experience_saved/recalled events, and structured injection blocks per the V1 schema.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-09-02 14:30:59 +08:00
parent 6d48480b1c
commit 2ec6fdbe11
11 changed files with 675 additions and 58 deletions
+11 -8
View File
@@ -66,22 +66,25 @@ test('formatExperienceInjectionLine includes structured hints', () => {
problem: '公网访问失败',
result: 'success',
confidence: 0.9,
createdAt: Date.parse('2026-09-15T00:00:00Z'),
environment: { runtime: '103', components: ['caddy', 'portal'] },
action: { executor: 'goose', steps: ['edit server.rs', 'reload caddy'] },
});
assert.match(line, /部署: 摘要/);
assert.match(line, /问题: 公网访问失败/);
assert.match(line, /结果: success, conf=0.9/);
assert.match(line, /环境: 103 · caddy \+ portal/);
assert.match(line, /\[2026-09\] 公网访问失败 \(success, conf=0.9\)/);
assert.match(line, /环境: 103 \+ caddy \+ portal/);
assert.match(line, /处理: edit server.rs → reload caddy/);
assert.match(line, /摘要: 摘要/);
});
test('formatExperienceInjectionBlock wraps lines with header', () => {
const block = formatExperienceInjectionBlock([
{ title: 'A', body: 'one' },
{ title: 'B', body: 'two' },
{ title: 'A', body: 'one', createdAt: Date.parse('2026-01-01T00:00:00Z') },
{ title: 'B', body: 'two', createdAt: Date.parse('2026-02-01T00:00:00Z') },
]);
assert.match(block, /^# 相关经验/);
assert.match(block, /- A: one/);
assert.match(block, /- B: two/);
assert.match(block, /\[2026-01\] A/);
assert.match(block, /摘要: one/);
assert.match(block, /\[2026-02\] B/);
});
test('buildMindspaceJobExperiencePayload maps failed jobs to failure result', () => {