407 Commits

Author SHA1 Message Date
root
274789a76a feat: wire llmStatsService into GameLoop
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:25:02 +00:00
root
9f31144430 feat: schema migration v1→v2 adding llm_call_log table
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:23:47 +00:00
root
b9edbee77d feat: instrument llmService to record calls via llmStatsService
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:22:11 +00:00
root
478ca06818 feat: add llmStatsService with SQLite persistence and aggregation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:20:26 +00:00
root
a6c92e7f99 feat: include retry count in openRouterClient CompletionSuccess
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:17:45 +00:00
root
f3186f6020 feat: add model pricing config and cost calculation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:15:57 +00:00
root
fb78d8cc9c feat: add LLM analytics types and socket events to shared
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:14:55 +00:00
root
d11f19e703 docs: add LLM analytics implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:12:38 +00:00
root
703b940e9d docs: add LLM analytics tracking design
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:08:10 +00:00
root
6712942436 fix: address code review — auth gating, subscription cleanup, debounce, npcBrainSystem
- 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>
2026-03-10 02:42:51 +00:00
root
e5715ec467 feat: wire all gameplay systems to RuntimeConstants
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>
2026-03-10 02:35:39 +00:00
root
701411c9a4 feat: integrate Admin and Log panels into LeftPanel and GameScene
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:28:32 +00:00
root
926bdc6687 feat: add AdminPanel UI component with password gate and constant editor
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:25:51 +00:00
root
a897dbfee4 feat: add LogPanel UI component
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:25:21 +00:00
root
39cb094110 feat: add admin and log socket methods to SocketClient
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:25:03 +00:00
root
e2670b0c34 feat: add admin auth and log streaming socket handlers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:23:46 +00:00
root
ff53096d94 feat: wire LogService into LLM layer for error/warning logging
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:22:20 +00:00
root
191770acbe feat: wire LogService into network layer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:21:08 +00:00
root
0d8573e11f feat: wire LogService + RuntimeConstants into GameLoop
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>
2026-03-10 02:19:55 +00:00
root
0d93574e76 feat: add RuntimeConstants service with get/update/reset
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:17:50 +00:00
root
f8cb83481e feat: add LogService with ring buffer and subscriber push
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:17:48 +00:00
root
778eeb3832 feat: add TunableConstants, LogEntry types and socket events
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:16:27 +00:00
root
186536d95c docs: Admin & Log panel implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:13:37 +00:00
root
43c3709293 docs: Admin & Log panel design
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 02:09:55 +00:00
root
0127eeaae6 fix: remove quotes around backstory display
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 01:51:25 +00:00
root
377b24d225 fix: clean up raw JSON backstories on load from save
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>
2026-03-10 01:43:47 +00:00
root
ae723342c9 fix: strip NPC name prefix from thought display
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 01:37:02 +00:00
root
b347ada878 feat: add D (Desires) tab to NPC info panel
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 01:34:46 +00:00
root
176ca88983 docs: NPC panel cleanup implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 01:32:53 +00:00
root
b28046c5f2 docs: NPC panel cleanup design — desires tab, thought name stripping
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 01:32:14 +00:00
root
034f799431 feat: multi-tile trees with treesnstone tileset and trunk bridging
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>
2026-03-10 01:22:47 +00:00
root
c2b22aab4e feat: NPC desire system — motivation layer for emergent behavior
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>
2026-03-10 00:16:00 +00:00
root
a8f27a869d 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>
2026-03-10 00:14:35 +00:00
root
7a16872bb9 feat: display NPC desires in info panel
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>
2026-03-10 00:07:14 +00:00
root
f3591e68d7 feat: industrySystem scores recipes by desire match
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>
2026-03-10 00:07:09 +00:00
root
c548d0ac05 test: add desire lifecycle integration test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 00:04:30 +00:00
root
7ef9636307 feat: wire desire systems into GameLoop and spawner
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 00:02:40 +00:00
root
733cdfb20f feat: send desires to client via state serializer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 00:00:20 +00:00
root
a63ff776de feat: persist desires component in entity serializer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:59:47 +00:00
root
cf5558ce0f feat: pass NPC desires into invention prompts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:59:29 +00:00
root
808ffc06c6 feat: add desire generator system for periodic and event-driven desire creation
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>
2026-03-09 23:55:29 +00:00
root
5835206171 feat: add combined backstory + desires LLM generator
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>
2026-03-09 23:50:51 +00:00
root
979a318651 refactor: reframe LLM templates from medieval to frontier settlement
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:47:21 +00:00
root
f94a6363aa feat: add desire fulfillment system with criteria checks
Checks NPC desires against world state every 100 ticks and removes
fulfilled ones. Supports own_item, own_item_category, structure_exists,
relationship_tier, recipe_exists criteria. building_exists and custom
always return false (deferred).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:44:46 +00:00
root
d3706c90b8 feat: add desireConfig with tuning values
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:42:04 +00:00
root
57e8b3a98a feat: add Desire types to shared
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:41:07 +00:00
root
dfd2b9e6e4 docs: add NPC desire system implementation plan
14 bite-sized tasks covering types, config, fulfillment system,
template overhaul, backstory+desires generator, desire generator
system, industry scoring, invention integration, persistence,
client display, and integration testing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:37:15 +00:00
root
ac9c881610 docs: add NPC desire system design
Motivation layer giving NPCs personal desires (0-3 per NPC) that
drive crafting priorities, influence invention, and create emergent
stories. Hybrid LLM approach: traits at spawn + event-driven updates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:31:50 +00:00
root
ee7f22c2c3 feat: ensure default stockpiles on load, use full stat names in backstory prompts
- Add ensureDefaultStockpiles() to handle saves from before stockpile spawning
- Switch backstory prompt stat formatting from abbreviations (STR, DEX) to
  full names (strength, dexterity) for better LLM comprehension
- Add prior design/plan docs for LLM fallback and NPC sleep system

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 22:05:14 +00:00
root
1da03c46f3 refactor: extract findNearestStockpile helper in npcBrainSystem
Deduplicates stockpile-finding logic that was repeated in the dropoff
preservation block and the target selection block.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 21:55:26 +00:00