From 6ccb580ca1b1efffcd68afd1324f039604484de9 Mon Sep 17 00:00:00 2001 From: GRayHook Date: Wed, 17 Jun 2026 11:17:30 +0700 Subject: [PATCH] =?UTF-8?q?Phase=205:=20add=20getKeptEntries=20=E2=80=94?= =?UTF-8?q?=20branch=20slice=20from=20firstKeptEntryId.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements kept-window boundary per SPEC §6.4 for dedup before re-inject. Co-authored-by: Cursor --- src/kept.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/kept.ts diff --git a/src/kept.ts b/src/kept.ts new file mode 100644 index 0000000..ad0a446 --- /dev/null +++ b/src/kept.ts @@ -0,0 +1,10 @@ +import type { SessionEntry } from "@earendil-works/pi-coding-agent"; + +/** Branch slice from firstKeptEntryId through tail (SPEC §6.4). */ +export function getKeptEntries(branch: SessionEntry[], firstKeptEntryId: string): SessionEntry[] { + const startIndex = branch.findIndex((entry) => entry.id === firstKeptEntryId); + if (startIndex < 0) { + return []; + } + return branch.slice(startIndex); +}