const MAX_SUMMARY_LENGTH = 2000;
/**
 * Build a markdown context summary from the current session state.
 * Includes: specs in progress, last 5 modified files, last 3 decisions.
 * Truncated to 2000 chars max.
 */
export function buildContextSnapshot(session) {
    const parts = [];
    parts.push(`## Session Summary`);
    parts.push(`- **Started**: ${session.startedAt}`);
    parts.push(`- **Tool calls**: ${String(session.toolCallCount)}`);
    parts.push('');
    // Active specs
    if (session.activeSpecs.length > 0) {
        parts.push('### Active Specs');
        for (const spec of session.activeSpecs) {
            parts.push(`- **${spec.specId}** (${spec.status}): ${spec.summary}`);
        }
        parts.push('');
    }
    // Last 5 modified files
    if (session.modifiedFiles.length > 0) {
        parts.push('### Recent Files');
        const recentFiles = session.modifiedFiles.slice(-5);
        for (const file of recentFiles) {
            parts.push(`- \`${file.path}\` (${file.action})`);
        }
        parts.push('');
    }
    // Last 3 decisions
    if (session.decisions.length > 0) {
        parts.push('### Recent Decisions');
        const recentDecisions = session.decisions.slice(-3);
        for (const d of recentDecisions) {
            const specRef = d.specId ? ` [${d.specId}]` : '';
            parts.push(`- ${d.decision}${specRef}`);
            if (d.rationale) {
                parts.push(`  _Rationale: ${d.rationale}_`);
            }
        }
        parts.push('');
    }
    const full = parts.join('\n');
    if (full.length <= MAX_SUMMARY_LENGTH) {
        return full;
    }
    return `${full.slice(0, MAX_SUMMARY_LENGTH - 3)}...`;
}
//# sourceMappingURL=context-snapshot.js.map