import { describe, expect, it } from "vite-plus/test"; import { ATTACHMENT_ONLY_BOOTSTRAP_PROMPT } from "@t3tools/shared/composerContextReferences"; import { buildPlanImplementationPrompt } from "../../proposedPlan"; import { buildComposerPromptHistoryEntries, recallableComposerPrompt, stepComposerPromptHistory, type ComposerPromptHistoryPosition, } from "./composerPromptHistory"; const entries = buildComposerPromptHistoryEntries([ { id: "m1", role: "user", text: "first" }, { id: "a1", role: "assistant", text: "reply" }, { id: "m2", role: "user", text: "second" }, { id: "m3", role: "user", text: "third" }, ]); function backward(position: ComposerPromptHistoryPosition | null, currentPrompt: string) { return stepComposerPromptHistory({ direction: "backward", entries, position, currentPrompt }); } function forward(position: ComposerPromptHistoryPosition | null, currentPrompt: string) { return stepComposerPromptHistory({ direction: "forward", entries, position, currentPrompt }); } describe("recallableComposerPrompt", () => { it.each([ "Render ", "Render\n\nhere", "Render <preview_annotation>", ])("strips an annotation whose comment contains a literal opening tag: %s", (comment) => { expect( recallableComposerPrompt( `Prompt\n\nComment: ${comment}\n`, ), ).toBe("Prompt"); }); it("preserves a malformed annotation containing a nested opening tag", () => { const text = "Prompt\n\nouter literal\n\ninner\n"; expect(recallableComposerPrompt(text)).toBe(text); }); it("does not strip a terminal label embedded in ordinary prose", () => { expect( recallableComposerPrompt( "email@build:7\n\n- Build line 7:\n output\n", ), ).toBe("email@build:7"); }); it("strips legacy send-time context blocks and the ultrathink prefix", () => { const sent = "Ultrathink:\nInvestigate this\n\n\n- Terminal 1 lines 12-13:\n 12 | git status\n 13 | On branch main\n\n\n\n-