Initial commit: Brachnha Insight project setup
- Next.js 14+ with App Router and TypeScript - Tailwind CSS and ShadCN UI styling - Zustand state management - Dexie.js for IndexedDB (local-first data) - Auth.js v5 for authentication - BMAD framework integration Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
28
tests/unit/prompt-engine.test.ts
Normal file
28
tests/unit/prompt-engine.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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}`);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user