Files
shd.build/src/lib/ai/mechanic-developer-handoff.test.ts
T
jb dd84dff055
Validate and deploy production / validate (push) Successful in 23s
Validate and deploy staging / validate (push) Successful in 50s
Validate and deploy production / deploy (push) Failing after 40s
Validate and deploy staging / deploy (push) Failing after 7s
feat: add community publishing and news syndication
2026-08-01 21:42:09 -04:00

75 lines
2.4 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');
});
});