diff --git a/plugins/linkedin-thought-leadership/hooks/scripts/session-start.mjs b/plugins/linkedin-thought-leadership/hooks/scripts/session-start.mjs index 9ee2816..ea09793 100644 --- a/plugins/linkedin-thought-leadership/hooks/scripts/session-start.mjs +++ b/plugins/linkedin-thought-leadership/hooks/scripts/session-start.mjs @@ -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') {