Add PreCompact hook for conversation archiving, remove /clear command
- Add PreCompact hook in agent-runner that archives conversations before compaction, using session summary from sessions-index.json for filename - Remove /clear command (programmatic compaction not supported by SDK) - Add /add-clear to RFS for future implementation - Update CLAUDE.md templates with memory system instructions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
18
src/index.ts
18
src/index.ts
@@ -13,10 +13,8 @@ import {
|
||||
ASSISTANT_NAME,
|
||||
POLL_INTERVAL,
|
||||
STORE_DIR,
|
||||
GROUPS_DIR,
|
||||
DATA_DIR,
|
||||
TRIGGER_PATTERN,
|
||||
CLEAR_COMMAND,
|
||||
MAIN_GROUP_FOLDER,
|
||||
IPC_POLL_INTERVAL
|
||||
} from './config.js';
|
||||
@@ -81,22 +79,6 @@ async function processMessage(msg: NewMessage): Promise<void> {
|
||||
|
||||
const content = msg.content.trim();
|
||||
|
||||
if (content.toLowerCase() === CLEAR_COMMAND) {
|
||||
if (sessions[group.folder]) {
|
||||
const archived = loadJson<Record<string, Array<{ session_id: string; cleared_at: string }>>>(
|
||||
path.join(DATA_DIR, 'archived_sessions.json'), {}
|
||||
);
|
||||
if (!archived[group.folder]) archived[group.folder] = [];
|
||||
archived[group.folder].push({ session_id: sessions[group.folder], cleared_at: new Date().toISOString() });
|
||||
saveJson(path.join(DATA_DIR, 'archived_sessions.json'), archived);
|
||||
delete sessions[group.folder];
|
||||
saveJson(path.join(DATA_DIR, 'sessions.json'), sessions);
|
||||
}
|
||||
logger.info({ group: group.name }, 'Session cleared');
|
||||
await sendMessage(msg.chat_jid, `${ASSISTANT_NAME}: Conversation cleared. Starting fresh!`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TRIGGER_PATTERN.test(content)) return;
|
||||
|
||||
// Get messages since last agent interaction to catch up the session
|
||||
|
||||
Reference in New Issue
Block a user