0f013b455e
- Added LaTeX math and Mermaid allowances in terminal and final-chat prompts. - Added inline math tokenization in TUI for $, $$, \(\), and \[\]. - Added LaTeX-to-Unicode conversion helpers and exports for math rendering. - Fixed inline math detection to skip escaped dollars and currency-like spans.
46 lines
1.4 KiB
TypeScript
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("In user-visible terminal prose and final chat");
|
|
expect(promptText).toContain("you MAY use LaTeX math delimiters");
|
|
expect(promptText).toContain("LaTeX math commands");
|
|
});
|
|
});
|