import assert from "node:assert/strict";
import test from "node:test";
import { buildSystemPromptAugmentation, buildTopLevelSystemPrompt } from "../src/llm/message-content.js";

test("system prompt augmentation includes date and default location", () => {
  const prompt = buildSystemPromptAugmentation(undefined, new Date("2026-05-24T15:30:00Z"));

  assert.equal(prompt, "Current date: 2026-05-24.\nUser location: San Francisco, CA.");
});

test("system prompt augmentation uses provided user location", () => {
  const prompt = buildSystemPromptAugmentation("New York, NY", new Date("2026-05-24T15:30:00Z"));

  assert.equal(prompt, "Current date: 2026-05-24.\nUser location: New York, NY.");
});

test("top-level system prompt includes runtime context with existing system messages", () => {
  const prompt = buildTopLevelSystemPrompt(
    [{ role: "system", content: "Use concise answers." }],
    "Los Angeles, CA"
  );

  assert.match(prompt, /Current date: \d{4}-\d{2}-\d{2}\./);
  assert.match(prompt, /User location: Los Angeles, CA\./);
  assert.match(prompt, /Use concise answers\./);
});
