From a0e6d204a6d07133a33c0067e06a4cb38f5eff4d Mon Sep 17 00:00:00 2001 From: GRayHook Date: Wed, 17 Jun 2026 11:20:11 +0700 Subject: [PATCH] =?UTF-8?q?Phase=205:=20add=20filterSkillsNeedingReinject?= =?UTF-8?q?=20=E2=80=94=20kept-window=20dedup=20input=20for=20pendingReinj?= =?UTF-8?q?ect.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Returns tracked registered skills absent from kept user messages per SPEC §5.2 and §6.4. Co-authored-by: Cursor --- src/kept.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/kept.ts b/src/kept.ts index 9461103..6855872 100644 --- a/src/kept.ts +++ b/src/kept.ts @@ -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, + registeredNames: ReadonlySet, +): string[] { + const needing: string[] = []; + for (const skill of tracked) { + if (registeredNames.has(skill.name) && !keptPresent.has(skill.name)) { + needing.push(skill.name); + } + } + return needing; +}