/**
 * Compare two sessions and return what changed.
 * `older` is the previous session, `newer` is the current one.
 */
export function diffSessions(older, newer) {
    const oldSpecIds = new Set(older.activeSpecs.map((s) => s.specId));
    const newSpecIds = new Set(newer.activeSpecs.map((s) => s.specId));
    // Specs in newer but not in older
    const newSpecs = newer.activeSpecs.filter((s) => !oldSpecIds.has(s.specId));
    // Specs in older but not in newer (completed/removed)
    const completedSpecs = older.activeSpecs.filter((s) => !newSpecIds.has(s.specId));
    // Decisions in newer that don't exist in older
    const oldDecisionKeys = new Set(older.decisions.map((d) => `${d.timestamp}|${d.decision}`));
    const newDecisions = newer.decisions.filter((d) => !oldDecisionKeys.has(`${d.timestamp}|${d.decision}`));
    // File changes in newer not in older
    const oldFilePaths = new Set(older.modifiedFiles.map((f) => f.path));
    const fileChanges = newer.modifiedFiles.filter((f) => !oldFilePaths.has(f.path));
    return { newSpecs, completedSpecs, newDecisions, fileChanges };
}
/**
 * Format a session diff as a human-readable summary string.
 */
export function formatDiffSummary(diff) {
    const parts = [];
    if (diff.completedSpecs.length > 0) {
        parts.push(`${String(diff.completedSpecs.length)} spec(s) completed`);
    }
    if (diff.newSpecs.length > 0) {
        parts.push(`${String(diff.newSpecs.length)} new spec(s) started`);
    }
    if (diff.newDecisions.length > 0) {
        parts.push(`${String(diff.newDecisions.length)} new decision(s)`);
    }
    if (diff.fileChanges.length > 0) {
        parts.push(`${String(diff.fileChanges.length)} file(s) changed`);
    }
    if (parts.length === 0) {
        return 'No significant changes since last session.';
    }
    return `Since your last session: ${parts.join(', ')}.`;
}
//# sourceMappingURL=session-diff.js.map