Support live attribute restoration mechanics

This commit is contained in:
JB
2026-07-27 21:32:04 -04:00
parent 36dd018a4a
commit 568e46cd05
19 changed files with 979 additions and 31 deletions
@@ -0,0 +1,61 @@
import { describe, expect, it } from 'vitest';
import type { AiMechanicAuthoringRequest } from '$lib/ai/mechanic-authoring';
import {
AI_MECHANIC_AUTHORING_INSTRUCTIONS,
buildAiMechanicAuthoringInput
} from './mechanic-authoring-prompt';
const request: AiMechanicAuthoringRequest = {
context: {
sourceKind: 'talent',
sourceName: 'Predatory Aura',
sourceDescription: 'Restore Health based on the current Firepower Multiplier.'
},
currentDraft: {
version: 1,
simulationReadiness: 'captured_only',
scenarioInputs: [],
pools: [],
clauses: []
},
valueColumns: [
{ key: 'tierI', variantKey: 'I', label: 'TIER I' },
{ key: 'tierII', variantKey: 'II', label: 'TIER II' }
],
allowAssignedAbility: false,
allowProtocolUpgradeScaling: false,
transcript: []
};
describe('AI mechanic authoring prompt', () => {
it('advertises exact catalog Attribute references and displayed-percent semantics', () => {
const input = JSON.parse(buildAiMechanicAuthoringInput({
request,
attributes: [{
id: 'firepower-multiplier',
name: 'Firepower Multiplier',
description: null,
unit: '%',
type: null,
category: null,
calculationType: null
}],
events: [],
actions: [],
recipeKeys: []
}));
expect(input.canonicalCatalog.grammar.valueReferences).toContain('attribute');
expect(input.canonicalCatalog.grammar.referenceShapes).toContainEqual({
ref: {
source: 'attribute',
attributeId: 'replace-with-an-exact-catalog-attribute-id'
}
});
expect(input.examplesAndRules).toEqual(expect.arrayContaining([
expect.stringContaining('exact supplied catalog ID'),
expect.stringContaining('Divide that reference by 100')
]));
expect(AI_MECHANIC_AUTHORING_INSTRUCTIONS).toContain('Never invent an Attribute ID');
});
});