feat: track compaction count + verbose notice

This commit is contained in:
Peter Steinberger
2026-01-06 02:41:48 +01:00
parent 3c6dea3ef3
commit b30bae89ed
12 changed files with 293 additions and 6 deletions

View File

@@ -122,3 +122,32 @@ export async function ensureSkillSnapshot(params: {
return { sessionEntry: nextEntry, skillsSnapshot, systemSent };
}
export async function incrementCompactionCount(params: {
sessionEntry?: SessionEntry;
sessionStore?: Record<string, SessionEntry>;
sessionKey?: string;
storePath?: string;
now?: number;
}): Promise<number | undefined> {
const {
sessionEntry,
sessionStore,
sessionKey,
storePath,
now = Date.now(),
} = params;
if (!sessionStore || !sessionKey) return undefined;
const entry = sessionStore[sessionKey] ?? sessionEntry;
if (!entry) return undefined;
const nextCount = (entry.compactionCount ?? 0) + 1;
sessionStore[sessionKey] = {
...entry,
compactionCount: nextCount,
updatedAt: now,
};
if (storePath) {
await saveSessionStore(storePath, sessionStore);
}
return nextCount;
}