Files
oh-my-pi/packages/coding-agent/test/system-prompt-math.test.ts
T

46 lines
1.4 KiB
TypeScript

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("avoid using LaTeX math delimiters");
expect(promptText).toContain("LaTeX math commands");
expect(promptText).toContain("plain text / Unicode");
});
});