Files
VolcanicSecretary/src/agent/system-prompt.test.ts
2026-09-08 12:26:12 +00:00

43 lines
1.7 KiB
TypeScript

import { mkdtemp, rm, writeFile } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { currentTimeLine, memorySection, secretarySystemPrompt } from "./system-prompt.js";
describe("secretarySystemPrompt", () => {
it("mentions the timezone, the memory file, the inbox, and the script convention", () => {
const p = secretarySystemPrompt("Europe/Berlin");
expect(p).toContain("Europe/Berlin");
expect(p).toContain("MEMORY.md");
expect(p).toContain("inbox/");
expect(p).toContain("Print nothing and exit 0");
expect(p).toContain("schedule");
expect(p).toContain("send");
expect(p).toContain("Sending files");
});
});
describe("currentTimeLine", () => {
it("formats the given date in the given timezone", () => {
const line = currentTimeLine("Europe/Berlin", new Date("2026-09-06T10:00:00Z"));
expect(line).toContain("2026");
expect(line).toContain("12:00");
expect(line.endsWith("(Europe/Berlin)")).toBe(true);
});
});
describe("memorySection", () => {
it("returns an empty string when MEMORY.md is missing or blank, else a headed section", async () => {
const dir = await mkdtemp(path.join(os.tmpdir(), "secretary-mem-"));
try {
expect(memorySection(dir)).toBe("");
await writeFile(path.join(dir, "MEMORY.md"), " \n");
expect(memorySection(dir)).toBe("");
await writeFile(path.join(dir, "MEMORY.md"), "# Memory\n- likes tea\n");
expect(memorySection(dir)).toBe("\n\n# Current contents of MEMORY.md\n\n# Memory\n- likes tea");
} finally {
await rm(dir, { recursive: true, force: true });
}
});
});