Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: rebrand/ruvflow-umbrella
- Timestamp: 2026-02-10T16:34:56Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rUvandClaude Opus 4.5 committed 2026-02-10 16:34:56 +00:00
1 parent da2844037d
commit 3a708c1d96
1 file changed
+80
@@ -877,6 +877,86 @@ async function retrieveContext(backend, sessionId, budget) {
return header + lines.join('\n') + footer;
}
// ============================================================================
// Build custom compact instructions (exit code 0 stdout)
// Guides Claude on what to preserve during compaction summary
// ============================================================================
function buildCompactInstructions(chunks, sessionId, archiveResult) {
const parts = [];
parts.push('COMPACTION GUIDANCE (from context-persistence-hook):');
parts.push('');
parts.push(`All ${chunks.length} conversation turns have been archived to the transcript-archive database.`);
parts.push(`Session: ${sessionId} | Stored: ${archiveResult.stored} new, ${archiveResult.deduped} deduped.`);
parts.push('After compaction, archived context will be automatically restored via SessionStart hook.');
parts.push('');
// Collect unique tools and files across all chunks for preservation hints
const allTools = new Set();
const allFiles = new Set();
const decisions = [];
for (const chunk of chunks) {
const toolNames = [...new Set(chunk.toolCalls.map(tc => tc.name))];
for (const t of toolNames) allTools.add(t);
const filePaths = extractFilePaths(chunk.toolCalls);
for (const f of filePaths) allFiles.add(f);
// Look for decision indicators in assistant text
const assistantText = extractTextContent(chunk.assistantMessage);
if (assistantText) {
const lower = assistantText.toLowerCase();
if (lower.includes('decided') || lower.includes('choosing') || lower.includes('approach')
|| lower.includes('instead of') || lower.includes('rather than')) {
const firstLine = assistantText.split('\n').find(l => l.trim()) || '';
if (firstLine.length > 10) decisions.push(firstLine.slice(0, 120));
}
}
}
parts.push('PRESERVE in compaction summary:');
if (allFiles.size > 0) {
const fileList = [...allFiles].slice(0, 15).map(f => {
const segs = f.split('/');
return segs.length > 3 ? '.../' + segs.slice(-3).join('/') : f;
});
parts.push(`- Files modified/read: ${fileList.join(', ')}`);
}
if (allTools.size > 0) {
parts.push(`- Tools used: ${[...allTools].join(', ')}`);
}
if (decisions.length > 0) {
parts.push('- Key decisions:');
for (const d of decisions.slice(0, 5)) {
parts.push(` * ${d}`);
}
}
// Recent turns summary (most important context)
const recentChunks = chunks.slice(-5);
if (recentChunks.length > 0) {
parts.push('');
parts.push('MOST RECENT TURNS (prioritize preserving):');
for (const chunk of recentChunks) {
const userText = extractTextContent(chunk.userMessage);
const firstLine = userText.split('\n').find(l => l.trim()) || '';
const toolNames = [...new Set(chunk.toolCalls.map(tc => tc.name))];
parts.push(`- [Turn ${chunk.turnIndex}] ${firstLine.slice(0, 80)}${toolNames.length ? ` (${toolNames.join(', ')})` : ''}`);
}
}
// Cap at budget
let result = parts.join('\n');
if (result.length > COMPACT_INSTRUCTION_BUDGET) {
result = result.slice(0, COMPACT_INSTRUCTION_BUDGET - 3) + '...';
}
return result;
}
// ============================================================================
// Commands
// ============================================================================