Phase 12: recalculate pending on each compact — SPEC §16.6.

Every session_compact replans pendingReinject in defer mode; skipped reinject clears the queue unless manual compaction is waiting for the next user prompt.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-17 13:15:13 +07:00
parent 502ca39b3e
commit 09619d9dd8
3 changed files with 71 additions and 13 deletions
+19
View File
@@ -96,6 +96,25 @@ export function enqueueDeferredReinjectFromCompact(
);
}
/**
* Update pending queue after session_compact; each compact recalculates or clears (SPEC §16.6).
* Manual compaction with default settings keeps stale pending until the next user prompt.
*/
export function applyPendingReinjectAfterCompact(
state: ExtensionState,
compactionRuntime: CompactionRuntime,
shouldReinject: boolean,
planned: readonly string[],
): void {
if (shouldReinject) {
state.pendingReinject = [...planned];
return;
}
if (!compactionRuntime.clearPendingReinjectOnNextUserInput) {
state.pendingReinject = [];
}
}
/** Warn when re-injecting many skills; unlimited by default with soft warn above 3 (SPEC §15). */
export function maybeWarnManySkills(
skillCount: number,