Phase 5: add filterSkillsNeedingReinject — kept-window dedup input for pendingReinject.

Returns tracked registered skills absent from kept user messages per SPEC §5.2 and §6.4.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-17 11:20:11 +07:00
parent 9896e7efa6
commit a0e6d204a6
+16
View File
@@ -1,5 +1,6 @@
import type { SessionEntry } from "@earendil-works/pi-coding-agent";
import { parseSkillBlocksFromText } from "./detect.js";
import type { TrackedSkill } from "./state.js";
/** Branch slice from firstKeptEntryId through tail (SPEC §6.4). */
export function getKeptEntries(branch: SessionEntry[], firstKeptEntryId: string): SessionEntry[] {
@@ -54,3 +55,18 @@ export function skillsPresentInKeptWindow(
}
return present;
}
/** Tracked skills missing from kept window but still registered (SPEC §5.2, §6.4). */
export function filterSkillsNeedingReinject(
tracked: readonly TrackedSkill[],
keptPresent: ReadonlySet<string>,
registeredNames: ReadonlySet<string>,
): string[] {
const needing: string[] = [];
for (const skill of tracked) {
if (registeredNames.has(skill.name) && !keptPresent.has(skill.name)) {
needing.push(skill.name);
}
}
return needing;
}