import { afterEach, beforeEach, describe, expect, it } from "bun:test"; import * as fs from "node:fs"; import * as os from "node:os"; import * as path from "node:path"; import { buildSystemPrompt } from "@oh-my-pi/pi-coding-agent/system-prompt"; import { cleanupTempHome } from "./helpers/temp-home-cleanup"; const EMPTY_TREE = { rootPath: "", rendered: "", truncated: false, totalLines: 0, agentsMdFiles: [], }; describe("system prompt mathematical formatting", () => { let tempDir = ""; let tempHomeDir = ""; let originalHome: string | undefined; beforeEach(() => { tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-prompt-math-")); tempHomeDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-prompt-math-home-")); originalHome = process.env.HOME; process.env.HOME = tempHomeDir; }); afterEach(cleanupTempHome(() => ({ tempDir, tempHomeDir, originalHome }))); it("renders mathematical formatting constraints into the system prompt", async () => { const { systemPrompt } = await buildSystemPrompt({ cwd: tempDir, contextFiles: [], skills: [], rules: [], toolNames: [], workspaceTree: { ...EMPTY_TREE, rootPath: tempDir }, }); const promptText = systemPrompt.join("\n\n"); expect(promptText).toContain("In user-visible terminal prose and final chat"); expect(promptText).toContain("you MAY use LaTeX math delimiters"); expect(promptText).toContain("LaTeX math commands"); }); });