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); +}