feat: auto memory pipeline — host-driven Memento recall/reflect
Add automatic memory integration so EJClaw host directly calls Memento MCP for recall at session start and reflect on compact, removing reliance on agent voluntary tool use. Stage 1: New sessions get room memory briefing injected into system prompt (CLAUDE.md / AGENTS.md) via host-side MCP client. Stage 2: PreCompact hook automatically calls reflect + remember to persist session summaries as room-memory fragments. Also restores missing source files (token-rotation, codex-token-rotation, claude-usage exports) to fix full build from source. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
55
src/memento-client.test.ts
Normal file
55
src/memento-client.test.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {
|
||||
buildRoomMemoryKey,
|
||||
formatRoomMemoryBriefing,
|
||||
} from './memento-client.js';
|
||||
|
||||
describe('memento-client helpers', () => {
|
||||
it('builds a stable room memory key from the group folder', () => {
|
||||
expect(buildRoomMemoryKey('ejclaw')).toBe('room:ejclaw');
|
||||
});
|
||||
|
||||
it('formats recalled fragments into a compact session briefing', () => {
|
||||
const briefing = formatRoomMemoryBriefing('room:ejclaw', [
|
||||
{
|
||||
id: 'frag-1',
|
||||
content: '사용자는 세션 리셋 후에도 방 맥락이 이어지길 원함.',
|
||||
type: 'decision',
|
||||
topic: 'room-memory',
|
||||
},
|
||||
{
|
||||
id: 'frag-2',
|
||||
content: '자동 recall/reflect를 호스트가 책임지는 방향으로 합의함.',
|
||||
type: 'fact',
|
||||
},
|
||||
]);
|
||||
|
||||
expect(briefing).toContain('## Shared Room Memory');
|
||||
expect(briefing).toContain('room:ejclaw');
|
||||
expect(briefing).toContain(
|
||||
'[decision / room-memory] 사용자는 세션 리셋 후에도 방 맥락이 이어지길 원함.',
|
||||
);
|
||||
expect(briefing).toContain(
|
||||
'[fact] 자동 recall/reflect를 호스트가 책임지는 방향으로 합의함.',
|
||||
);
|
||||
});
|
||||
|
||||
it('trims overly long briefings to the configured max length', () => {
|
||||
const briefing = formatRoomMemoryBriefing(
|
||||
'room:ejclaw',
|
||||
[
|
||||
{
|
||||
id: 'frag-1',
|
||||
content: 'a'.repeat(300),
|
||||
type: 'fact',
|
||||
},
|
||||
],
|
||||
120,
|
||||
);
|
||||
|
||||
expect(briefing).toBeDefined();
|
||||
expect(briefing!.length).toBeLessThanOrEqual(120);
|
||||
expect(briefing!.endsWith('…')).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user