fix: emit desire_fulfilled events, populate LLM context, fix category scoring
- desireFulfillmentSystem records memory events when desires are fulfilled - desireGeneratorSystem populates recentEvents and recentInventions template vars - industrySystem own_item_category scoring now checks recipe output category Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import type { EntityId, Desire, Stats } from '@dflike/shared';
|
||||
import type { World } from '../ecs/World.js';
|
||||
import type { LlmService } from '../llm/llmService.js';
|
||||
import type { EventMemoryService } from '../llm/eventMemoryService.js';
|
||||
import type { InventionTimeline } from '../industry/inventionTimeline.js';
|
||||
import { desireConfig } from '../config/desireConfig.js';
|
||||
import { getEffectiveStat } from './statHelpers.js';
|
||||
import { formatStatsForPrompt, getWorldContext, validateDesire } from '../llm/backstoryGenerator.js';
|
||||
@@ -10,7 +12,10 @@ export interface DesireGeneratorSystem {
|
||||
triggerEvent(world: World, entityId: number, trigger: string, tick: number): void;
|
||||
}
|
||||
|
||||
export function createDesireGeneratorSystem(llmService: LlmService): DesireGeneratorSystem {
|
||||
export function createDesireGeneratorSystem(
|
||||
llmService: LlmService,
|
||||
eventMemoryService?: EventMemoryService,
|
||||
): DesireGeneratorSystem {
|
||||
const pendingEntities = new Set<EntityId>();
|
||||
|
||||
function canAddDesire(world: World, entityId: number): boolean {
|
||||
@@ -38,11 +43,22 @@ export function createDesireGeneratorSystem(llmService: LlmService): DesireGener
|
||||
const context = getWorldContext(world);
|
||||
const currentDesireList = currentDesires.map(d => d.description).join('; ') || 'none';
|
||||
|
||||
const recentEvents = eventMemoryService
|
||||
? eventMemoryService.getRecentEvents(entityId, 5).map(e => e.detail).join('; ')
|
||||
: '';
|
||||
|
||||
const timeline = world.getSingleton<InventionTimeline>('inventionTimeline');
|
||||
const recentInventions = timeline
|
||||
? timeline.getSummaries().slice(-5).map(s => s.name).join(', ')
|
||||
: '';
|
||||
|
||||
const variables: Record<string, string> = {
|
||||
npcName: name,
|
||||
stats: formatStatsForPrompt(stats),
|
||||
backstory,
|
||||
currentDesires: currentDesireList,
|
||||
recentEvents: recentEvents || 'none',
|
||||
recentInventions: recentInventions || 'none',
|
||||
resourceTypes: context.resourceTypes,
|
||||
recipeList: context.recipeList,
|
||||
structureList: context.structureList,
|
||||
|
||||
Reference in New Issue
Block a user