Design for LLM-driven emergent crafting and invention system.
NPCs gather resources from terrain, craft at workshops, and
occasionally have eureka moments where an LLM invents new items.
Updates LLM roadmap: this becomes item 2.2, old goal selection
splits into 2.5 (POI naming).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements LLM-powered narration for NPC social interactions:
- Rate limits updated to 20 RPM / 1000 per day (OpenRouter free tier)
- NarrationEvent type with template fallback text generator
- NarrationService with rolling event buffer and LLM priority queuing
- Narration emitter wired between social and relationship systems
- Socket.io events for real-time narration delivery
- Tabbed left panel (Stats + Events) replacing old Superlatives panel
- Recent events section in NPC info panel
- Follow tracking via socket for LLM narration priority
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Restore subscribeSuperlatives/unsubscribeSuperlatives/onSuperlativesUpdate
on SocketClient (lost during Task 5 refactor)
- Fix EventsFeed.updateEvent to rebuild entire element when LLM narration
arrives (names may be in different positions)
- Remove dead setFollowedEntity method from GameLoop (replaced by
SocketServer.rebuildFollowedEntityIds)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds follow-npc client event so the server knows which NPCs are being
watched, enabling priority LLM narration for followed entity interactions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Show the last 3 narration events involving the followed NPC in the
Status tab, between the activity label and the diamond separator.
Events update live when new narrations arrive or LLM text replaces
template text.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract SuperlativesPanel into content-only component, create LeftPanel
as the outer shell with two tabs (S for Stats, E for Events), and add
EventsFeed component for displaying narration events with clickable
NPC names and auto-scroll behavior.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire narration events through the socket layer so clients receive
real-time narration updates. Server emits narration-event on creation,
narration-update when LLM text arrives, and narration-history on connect.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removes duplicated local version that had different format.
Also brings backstoryGenerator.ts into the worktree from main.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add narrationEmitter system that reads completed interactions from
socialState.lastOutcome and feeds them to the NarrationService. It runs
between socialSystem and relationshipSystem to capture outcomes before
they are cleared. Includes pair deduplication, proposal detection,
priority marking for followed NPCs and high-value relationships, and
personality formatting for LLM prompts.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements NarrationService that manages a rolling buffer of 50 narration events,
generates immediate template fallback text, and queues LLM generation for priority
interactions and proposals (respecting daily limits).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Define NarrationEvent and NarrationOutcome types in shared package for
social interaction narration. Add generateFallbackNarration() with
randomized templates for each outcome type (positive, negative,
proposal_accepted, proposal_rejected) to provide immediate text when
LLM narration is unavailable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Raise requestsPerMinute from 10 to 20 and add requestsPerDay (1000) to
match OpenRouter free-tier limits. The generation queue now tracks daily
usage and resets at midnight, resolving requests with null once the cap
is hit. Both GenerationQueue and LlmService expose isDailyLimitReached().
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add trunk decoration layer to GameMap and mapGenerator
- Load trunk.png asset in BootScene
- Increase superlatives panel size and font sizes for readability
- Simplify mapGenerator (remove procedural terrain features)
- Add LLM integration planning documents
- Remove stale day-night cycle worktree plans
- Update local Claude settings
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add backstory element to the Status tab between the activity label and
diamond separator. When a backstory arrives from the LLM, it fades in
with italic styling. Empty backstories remain hidden.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Trigger fire-and-forget backstory generation whenever an NPC spawns,
both during initial spawn and via player spawn-npc requests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds formatStatsForPrompt to convert Stats into prompt-friendly abbreviations
and generateBackstory to call the LLM service with the backstory template,
writing the result back to the entity's backstory component.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Initialize empty backstory on NPC spawn, serialize it for broadcast,
and add test coverage for the new component.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Combines config, OpenRouter client, generation queue, and template
rendering into a simple generate(templateName, variables) API. When
disabled (no API key), returns a no-op implementation. Includes
backstory, socialNarration, and innerMonologue prompt templates.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reads API key and model from environment variables. LLM is disabled by
default and auto-enables when OPENROUTER_API_KEY is set.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>