import { describe, it, expect } from 'vitest'; import { createInMemoryMemoryStore } from '@waggle/memory-contract'; import { Orchestrator } from '../src/orchestrator.js'; describe('buildSystemPrompt goal-ancestry (#6)', () => { function orch(goalAncestry?: { project?: string; goal?: string; mission?: string; task?: string }) { return new Orchestrator({ memory: createInMemoryMemoryStore(), ...(goalAncestry ? { goalAncestry } : {}) }); } it("renders the Why You're Here section after setGoalAncestry", async () => { const o = orch(); o.setGoalAncestry({ project: 'Acme Redesign', goal: 'Ship the live-output pane' }); const prompt = await o.buildSystemPrompt(); expect(prompt).toContain("# Why You're Here"); expect(prompt).toContain('Project: Acme Redesign'); expect(prompt).toContain('Goal: Ship the live-output pane'); }); it('omits the section entirely when no ancestry is set', async () => { expect(await orch().buildSystemPrompt()).not.toContain("# Why You're Here"); }); it('accepts goalAncestry via the constructor config', async () => { expect(await orch({ project: 'P' }).buildSystemPrompt()).toContain('Project: P'); }); it('clears the section when setGoalAncestry(null)', async () => { const o = orch({ project: 'P' }); expect(await o.buildSystemPrompt()).toContain('Project: P'); o.setGoalAncestry(null); expect(await o.buildSystemPrompt()).not.toContain("# Why You're Here"); }); });