import { describe, it, expect } from 'vitest'; // @ts-ignore - Module likely not created yet import { PromptEngine } from '@/lib/llm/prompt-engine'; describe('PromptEngine (Ghostwriter)', () => { it('should construct a grounded prompt with user insight', () => { // GIVEN: A user insight and chat history const history = [ { role: 'user', content: 'I feel stupid.' }, { role: 'assistant', content: 'Why?' }, { role: 'user', content: 'I made a typo.' } ]; const insight = "I need a checklist for typos."; // WHEN: Constructing the prompt // @ts-ignore const prompt = PromptEngine.constructGhostwriterPrompt(history, insight); // THEN: The system prompt should enforce grounding expect(prompt[0].role).toBe('system'); expect(prompt[0].content).toContain('You are an expert Ghostwriter'); expect(prompt[0].content).toContain('Ground your answer in the user insight'); // R-2.1 Mitigation // AND: The user insight should be clearly labeled const lastMessage = prompt[prompt.length - 1]; expect(lastMessage.content).toContain(`INSIGHT: ${insight}`); }); });