Every failure path was silent — LLM nulls, parse failures, validation
rejections, and promise errors were all swallowed. Adds per-attempt
logging at each gate plus a periodic summary of NPC/inventory/item state.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix LLM stats panel stuck on "Loading stats..." by requesting stats
immediately after admin authentication succeeds
- Add retry mechanism for backstory generation (up to 3 attempts with
increasing delays) so transient failures don't permanently skip NPCs
- Fix stale model bug: queued LLM requests now use the current model at
dequeue time instead of capturing it at enqueue time, so fallback
model switches take effect for pending requests
- Add per-template maxTokens (backstory: 350, invention: 300, desire:
250) to prevent "length" finish truncation on structured JSON responses
- Remove unused "reasoning" field from backstory prompt to reduce token usage
- Add failure logging throughout LLM pipeline (backstory null results,
queue errors) for better diagnostics
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract shared WORLD_PREAMBLE and prepend to all system prompts
- Remove duplicated world-setting text from individual templates
- Add server/saves/ and treesnstone.zip to .gitignore
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Wire npcBrainSystem to RuntimeConstants (was using hardcoded shared imports)
- Add auth gating on admin-update-constant and admin-reset-defaults sockets
- Unsubscribe from previous tab's data sources on left-panel tab switch
- Use per-key debounce timers in AdminPanel to avoid dropped changes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace direct constant imports with rc.get() calls in needsDecaySystem,
socialSystem, statModifierSystem, movementSystem, gatheringSystem,
craftingSystem, buildingSystem, and SocketServer. All system functions
now accept a RuntimeConstants parameter, enabling live-tuning of game
constants via the admin panel.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace direct constant imports (TICK_RATE, BROADCAST_EVERY_N_TICKS,
ENERGY_DECAY_PER_TICK, DAY_NIGHT_RATIO) with RuntimeConstants lookups.
Add LogService for autosave logging and tick overrun detection.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Backstories stored as raw JSON (containing desires) are now parsed
on deserialization to extract just the backstory text.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace single-tile tree rendering with 6 multi-tile tree variants using
the treesnstone.png tileset. Each tree is 3 tiles wide with canopy tiles
on the decorations layer (above characters) and ground/shadow tiles on
the trunkDecorations layer (below characters). Add trunk bridge tiles
(tile 41) behind transparent canopy areas to connect canopy to ground
visually, fixing floating canopy appearance.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds 0-3 personal desires per NPC that drive crafting priorities,
influence invention, and create emergent stories. Hybrid LLM approach:
traits generated at spawn + event-driven updates.
Key components:
- Desire types (material/social/shelter/comfort/community/creative)
- Fulfillment checking system (7 criteria types, runs every 100 ticks)
- Desire generator system (periodic + event-driven LLM generation)
- Combined backstory+desires LLM generation at spawn
- Industry system scores recipes by desire match
- Desires passed into invention prompts
- Persistence, wire protocol, and client display
- All LLM templates reframed from medieval to frontier settlement
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 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>
Shows category-colored diamond bullets for active desires and
placeholder slots in the Status tab, between backstory and thoughts.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds scoreCraftableRecipes helper that scores recipes based on NPC
desires (priority * 10 for own_item match). Falls back to first
available when no desires match.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Factory-function system that generates new desires via LLM based on
periodic stat-based probability checks and external event triggers.
Tracks pending entities to prevent duplicate in-flight requests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add backstoryAndDesires and desireGeneration templates. Rewrite
backstoryGenerator with getWorldContext, validateDesire, and
generateBackstoryAndDesires helpers while keeping legacy generateBackstory
for backward compatibility. Add comprehensive tests (22 cases).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>