Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
import { describe, expect, test } from "vitest";
import { buildSystemPrompt } from "./system-prompt";
describe("buildSystemPrompt", () => {
test("includes the current date and time in ISO 8601 format", () => {
const before = new Date();
const prompt = buildSystemPrompt("My Workspace");
const after = new Date();
const match = prompt.match(
/The current date and time is: (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z) \(UTC\)/,
);
expect(match).not.toBeNull();
// oxlint-disable-next-line typescript/no-non-null-assertion
const promptDate = new Date(match![1]);
expect(promptDate.getTime()).toBeGreaterThanOrEqual(before.getTime());
expect(promptDate.getTime()).toBeLessThanOrEqual(after.getTime());
});
test("explains the context notes it gets in Slack", () => {
const prompt = buildSystemPrompt("Acme Corp");
expect(prompt).toContain("[2026-10-16 08:30 UTC] <@U123>");
expect(prompt).toContain("read_slack_channel with `before`");
expect(prompt).toContain("read_slack_message");
expect(prompt).toContain("approved cards already created in this thread");
expect(prompt).toContain(
"pass that time as `date` to create_status_report",
);
});
test("never denies an incident without naming what exists", () => {
const prompt = buildSystemPrompt("Acme Corp");
expect(prompt).toContain(
"Check both (list_incidents and list_status_reports)",
);
expect(prompt).toContain("Never say there is no incident without naming");
});
test("includes the workspace name", () => {
const prompt = buildSystemPrompt("Acme Corp");
expect(prompt).toContain('workspace "Acme Corp"');
});
test("tells the model a write call drafts a card instead of executing", () => {
const prompt = buildSystemPrompt("Acme Corp");
expect(prompt).toContain("does NOT execute");
expect(prompt).toContain("Approve/Cancel");
// The two ways the model strands the user without a card.
expect(prompt).toContain("NEVER write the draft out as message text");
expect(prompt).toContain("shall I go ahead?");
// notify is a button, so the model must not spend a turn asking.
expect(prompt).toContain("NEVER ask whether to notify subscribers");
// The card lands after the answer; "card's up 👆" points at nothing.
expect(prompt).toContain("Cards are posted BELOW your message");
});
test("guides the model on componentImpacts", () => {
const prompt = buildSystemPrompt("Acme Corp");
expect(prompt).toContain("componentImpacts");
expect(prompt).toContain("major_outage");
// resolve auto-clears impacts; the model must not publish a manual clear.
expect(prompt).toContain("clears every remaining impact");
// partial recovery before resolve IS reported manually, as operational.
expect(prompt).toContain("Recovery counts as a change");
});
test("forbids guessing monitor and notification ids", () => {
const prompt = buildSystemPrompt("Acme Corp");
expect(prompt).toContain("call list_monitors FIRST");
expect(prompt).toContain("call list_notifications FIRST");
});
test("asks for short, direct replies", () => {
const prompt = buildSystemPrompt("Acme Corp");
expect(prompt).toContain("REPLY STYLE");
expect(prompt).toContain("Lead with the answer");
});
test("tells the model not to show internal ids", () => {
expect(buildSystemPrompt("Acme Corp")).toContain("NEVER show internal ids");
});
test("appends the context note as a section of its own", () => {
const prompt = buildSystemPrompt("Acme Corp", "\nSlack context:\n- note");
expect(prompt).toContain("\n\nSlack context:\n- note");
// Never glued onto the last bullet of the section above it.
expect(prompt).not.toContain("window.Slack context:");
});
test("appends nothing when there is no context note", () => {
expect(buildSystemPrompt("Acme Corp")).not.toContain("Slack context:");
});
});