feat(memory-v2): close Phase A with auto-review, product events, and H5 recall UI.
Add candidate auto-review pipeline, shadow audit tooling, admin metrics page, and user-visible memory recall hints in chat with phase-a readiness checks. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
formatMemoryRecallNotice,
|
||||
formatPersonalMemorySavedNotice,
|
||||
summarizePersonalMemoryObservation,
|
||||
buildMemoryRecallPreviews,
|
||||
} from './memory-v2-user-feedback.mjs';
|
||||
|
||||
test('summarizePersonalMemoryObservation extracts accepted previews', () => {
|
||||
const summary = summarizePersonalMemoryObservation({
|
||||
enabled: true,
|
||||
autoReviewed: 1,
|
||||
results: [{
|
||||
accepted: true,
|
||||
candidate: {
|
||||
status: 'accepted',
|
||||
content: '请记住我每周三下午做代码评审',
|
||||
policyReason: 'explicit_memory_request',
|
||||
memoryType: 'episodic',
|
||||
},
|
||||
}],
|
||||
});
|
||||
assert.equal(summary.savedPreviews.length, 1);
|
||||
assert.match(formatPersonalMemorySavedNotice(summary) ?? '', /已记住:请记住我每周三下午做代码评审/);
|
||||
});
|
||||
|
||||
test('formatMemoryRecallNotice formats recall count', () => {
|
||||
assert.equal(formatMemoryRecallNotice(2), '参考了你的 2 条记忆');
|
||||
assert.equal(formatMemoryRecallNotice(0), null);
|
||||
});
|
||||
|
||||
test('buildMemoryRecallPreviews strips internal memory markers', () => {
|
||||
const previews = buildMemoryRecallPreviews([
|
||||
{ text: '[Memory Context] secret' },
|
||||
{ text: '我喜欢喝美式咖啡' },
|
||||
{ text: '每周三下午做代码评审,这是一个比较长的偏好描述用来测试截断逻辑是否正常工作' },
|
||||
], { limit: 3, maxLength: 12 });
|
||||
assert.deepEqual(previews, [
|
||||
'我喜欢喝美式咖啡',
|
||||
'每周三下午做代码评审,这…',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user