Open History to see the last commit
1import { describe, expect, it } from "vitest";
2
3import {
4 buildPlanImplementationThreadTitle,
5 buildPlanImplementationPrompt,
6 buildProposedPlanMarkdownFilename,
7 proposedPlanTitle,
8} from "./proposedPlan";
9
10describe("proposedPlanTitle", () => {
11 it("reads the first markdown heading as the plan title", () => {
12 expect(proposedPlanTitle("# Integrate RPC\n\nBody")).toBe("Integrate RPC");
13 });
14
15 it("returns null when the plan has no heading", () => {
16 expect(proposedPlanTitle("- step 1")).toBeNull();
17 });
18});
19
20describe("buildPlanImplementationPrompt", () => {
21 it("formats the plan exactly like the Codex follow-up handoff prompt", () => {
22 expect(buildPlanImplementationPrompt("## Ship it\n\n- step 1\n")).toBe(
23 "PLEASE IMPLEMENT THIS PLAN:\n## Ship it\n\n- step 1",
24 );
25 });
26});
27
28describe("buildPlanImplementationThreadTitle", () => {
29 it("uses the plan heading when building the implementation thread title", () => {
30 expect(buildPlanImplementationThreadTitle("# Integrate RPC\n\nBody")).toBe(
31 "Implement Integrate RPC",
32 );
33 });
34
35 it("falls back when the plan has no markdown heading", () => {
36 expect(buildPlanImplementationThreadTitle("- step 1")).toBe("Implement plan");
37 });
38});
39
40describe("buildProposedPlanMarkdownFilename", () => {
41 it("derives a stable markdown filename from the plan heading", () => {
42 expect(buildProposedPlanMarkdownFilename("# Integrate Effect RPC Into Server App")).toBe(
43 "integrate-effect-rpc-into-server-app.md",
44 );
45 });
46
47 it("falls back to a generic filename when the plan has no heading", () => {
48 expect(buildProposedPlanMarkdownFilename("- step 1")).toBe("plan.md");
49 });
50});