feat(linkedin): auto-prune content history entries older than 90 days

Adds pruneContentHistory call to session-start.mjs after week rollover.
Uses dynamic import() for state-updater.mjs. Non-critical: silently
skipped on failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-04-11 00:43:08 +02:00
commit d7a562fc45

View file

@ -149,6 +149,19 @@ if (existsSync(STATE_FILE)) {
weekResetNote = `Warning: Week rollover failed (${err.message}). Manual reset may be needed.`;
}
// Auto-prune Recent Posts entries older than 90 days
try {
const currentState = readFileSync(STATE_FILE, 'utf-8');
const { pruneContentHistory } = await import('./state-updater.mjs');
const pruneResult = pruneContentHistory(currentState, 90);
if (pruneResult && pruneResult.pruned > 0) {
writeFileSync(STATE_FILE, pruneResult.content, 'utf-8');
weekResetNote += (weekResetNote ? ' ' : '') + `Auto-pruned ${pruneResult.pruned} posts older than 90 days from Recent Posts.`;
}
} catch {
// Non-critical: don't block session start on pruning failure
}
// Build status line
let statusLine = `LinkedIn: ${postsThisWeek}/${weeklyGoal} posts this week | Streak: ${currentStreak} days`;
if (lastPostDate && lastPostDate !== 'null') {