Files
shd.build/src/lib/ai/mechanic-developer-handoff.test.ts
T

67 lines
2.2 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { buildMechanicDeveloperPrompt, type AiMechanicDeveloperHandoff } from './mechanic-developer-handoff';
const handoff: AiMechanicDeveloperHandoff = {
context: {
sourceKind: 'talent',
sourceName: 'Chain Reaction',
sourceDescription: 'Every third critical hit transfers the mark to a nearby enemy.'
},
valueColumns: [
{ key: 'tierI', variantKey: 'I', label: 'TIER I' },
{ key: 'tierII', variantKey: 'II', label: 'TIER II' }
],
allowAssignedAbility: false,
allowProtocolUpgradeScaling: false,
transcript: [{
questionId: 'transfer-target',
question: 'How is the next target selected?',
answer: 'Nearest enemy'
}],
response: {
status: 'capability_gap',
summary: 'The runtime cannot select a nearby transfer target.',
assumptions: ['The third hit consumes the current mark.'],
warnings: ['Target selection must be deterministic.'],
gaps: [{
area: 'runtime',
requiredBehavior: 'Select the nearest eligible enemy.',
whyUnsupported: 'The event has no ordered nearby-target collection.',
developerChange: 'Add a deterministic nearby-target selector.',
workaround: null
}],
meta: {
requestId: 'req_gap_123',
model: 'test-model',
inputTokens: 100,
outputTokens: 50,
totalTokens: 150
}
}
};
describe('mechanic developer handoff prompt', () => {
it('includes the exact analyzed source, clarification evidence, and required code change', () => {
const prompt = buildMechanicDeveloperPrompt(handoff);
expect(prompt).toContain(handoff.context.sourceDescription);
expect(prompt).toContain('How is the next target selected?');
expect(prompt).toContain('Answer: Nearest enemy');
expect(prompt).toContain('Add a deterministic nearby-target selector.');
expect(prompt).toContain('Assistant request ID: req_gap_123');
expect(prompt).toContain('Persistence round-trips the new representation');
});
it('omits empty optional sections', () => {
const prompt = buildMechanicDeveloperPrompt({
...handoff,
transcript: [],
response: { ...handoff.response, assumptions: [], warnings: [] }
});
expect(prompt).not.toContain('## Clarification history');
expect(prompt).not.toContain('## Assumptions');
expect(prompt).not.toContain('## Warnings');
});
});