Commit Graph

273 Commits

Author SHA1 Message Date
root 1acfc78e13 refactor(llm): remove isDailyLimitReached from downstream consumers
The LlmService interface no longer exposes isDailyLimitReached — model
switching is handled internally. Remove all checks in thoughtSystem,
inventionSystem, narrationService, and thoughtGenerator. Update mocks
in test files to match the new interface and remove obsolete daily-limit
test cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:03:09 +00:00
root 5c9edbde3c feat(llm): add model switching on 429 and usage tracking to llmService
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 15:59:42 +00:00
root 432d8aac2e feat(llm): add per-model usage counters for observability
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 15:57:29 +00:00
root 7485dec335 refactor(llm): remove daily limit gatekeeping from generationQueue
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 15:56:17 +00:00
root 760eda92f3 feat(llm): return structured rate-limit info on 429 responses
Add RateLimitInfo interface and CompletionResult type union so callers
can distinguish 429 rate limits from other errors. Includes isRateLimited
type guard and per-request model override in CompletionRequest.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 15:53:50 +00:00
root c2dbdcf146 feat(llm): add fallbackModel config, remove hardcoded model default
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 15:49:48 +00:00
root 4c24a016f1 docs: update CLAUDE.md with world persistence documentation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 15:21:11 +00:00
root 2f2248cb6d test(persistence): add full save/load integration test
Verifies complete save → close → reopen → load cycle with NPCs,
relationships, bonds, structures, and all event types (narration,
memory, stockpile, invention).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:43:19 +00:00
root 94fcafeea0 feat(persistence): add database indexes for query performance
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:38:35 +00:00
root eb639bf562 feat(server): integrate persistence into GameLoop and main.ts
Wire SaveManager into game startup/shutdown: constructor now checks for
existing save file and loads or creates new world accordingly. Add
autosave every 30s, final save on stop, and graceful shutdown signals.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:34:03 +00:00
root ca79868061 feat(persistence): add SaveManager orchestration class
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:29:21 +00:00
root 552d5fcafb feat(persistence): add persistence hooks to event services
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:25:16 +00:00
root 0fdf6c95af Merge branch 'worktree-agent-abadd094' 2026-03-09 14:18:47 +00:00
root 734abeb661 Merge branch 'worktree-agent-a3c95e37' 2026-03-09 14:18:34 +00:00
root 514a18ab54 feat(server): add entity serializer for save/load persistence
Add createEntityWithId to World for restoring entities with original IDs.
Implement saveEntities/loadEntities to persist NPCs, structures, relationships,
and bonds to SQLite, with proper Map serialization and transient state resets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:14:05 +00:00
root 52e94112e6 feat(persistence): add event serializer for narration, memory, stockpile, and inventions
Save/load functions for all four event tables with proper JSON serialization,
chronological ordering, per-entity grouping, and optional field handling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:12:22 +00:00
root 305e49789a feat(server): add world serializer for tile and metadata persistence
Implements saveTiles/loadTiles for round-tripping terrain, decorations,
trunk decorations, resource tiles, obstacles, food and rest positions
via SQLite. Adds saveMetadata/loadMetadata for tick and timestamp.
Includes database.ts (previously only in main worktree).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:11:08 +00:00
root f5c8d8661b feat(server): add SQLite database module with schema and connection management
Adds persistence/database.ts with openDatabase, getDatabase, closeDatabase,
getSchemaVersion, and CURRENT_SCHEMA_VERSION. Creates 10 tables (metadata,
tiles, entities, components, relationships, bonds, narration_events,
memory_events, stockpile_log, inventions) with WAL journal mode. Includes
8 tests covering table creation, schema versioning, connection reuse, and
data persistence across reopen.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:08:49 +00:00
root b30e7be48a chore: add better-sqlite3 dependency and saves directory
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:07:12 +00:00
root 1a7e68f211 docs: add world persistence implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 13:57:39 +00:00
root f9557fac3a docs: add world persistence design (SQLite-based save/load)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 13:51:23 +00:00
root 626b7f9a77 feat: add stocks panel, NPC panel tab rework, and stockpile pickup mechanic
- Add R(esources) tab to left panel showing stockpile totals and activity log
- Rework NPC panel tabs to vertical left-edge S/R/H/I style
- Add pickup system for NPCs to take materials from stockpiles for crafting
- Move inventory display to dedicated I(nventory) tab on NPC panel

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 03:01:02 +00:00
root 9a3e9d4757 fix(server): prioritize stockpile dropoff over wandering after gathering
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 03:00:55 +00:00
root 067976f9a2 feat(client): rework NPC panel tabs to vertical left-edge S/R/H/I style
Replace horizontal Status/Relations/History tabs with vertical single-letter
tabs (S/R/H/I) on the left edge of the panel. Add dedicated Inventory tab,
removing inventory from the Status tab. Panel structure reworked to flex row
with tab column + panel body, matching the LeftPanel's tab styling but mirrored.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:59:22 +00:00
root 797ea2d410 feat(client): wire StocksPanel into LeftPanel with R tab
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:55:52 +00:00
root 3dbf5b707b feat(client): add StocksPanel UI component
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:55:47 +00:00
root 803e6c9b8c feat(client): add stockpile socket callbacks to SocketClient
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:55:44 +00:00
root 9f77a84d6f feat(server): add pickup system for NPC stockpile material retrieval
NPCs can now retrieve crafting materials from stockpiles instead of
always gathering raw resources. The industry system checks if a
stockpile has needed materials before falling back to gathering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:52:37 +00:00
root 60c6d7808d feat(server): emit stockpile log events from dropoffSystem
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:49:24 +00:00
root 188a915732 feat(server): wire StockpileLog into GameLoop and SocketServer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:48:23 +00:00
root 9194a56848 feat(server): add StockpileLog singleton for tracking stockpile activity
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:47:35 +00:00
root 9e02cd973e feat(shared): add StockpileLogEntry type, pickup goal, and stockpile socket events
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:47:26 +00:00
root 35f3b4ea37 docs: add implementation plan for stocks panel, NPC tabs, and pickup mechanic
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:45:44 +00:00
root ca3e067e0b docs: add design for stocks panel, NPC tab rework, and pickup mechanic
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:42:27 +00:00
root d5ad7d5f7f feat(client): wire InventionsPanel into GameScene
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:46:21 +00:00
root e27f2381eb feat(client): add inventions tab with notification dot to LeftPanel
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:45:10 +00:00
root 6b932d12a7 feat(client): add InventionsPanel UI component
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:44:30 +00:00
root 01e6d9c526 feat(client): add invention event/history callbacks to SocketClient
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:43:38 +00:00
root 1271fc1d7f feat(server): emit invention-event and invention-history socket events
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:43:03 +00:00
root 3937b85ed6 feat(server): pass full invention data to timeline on registration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:41:53 +00:00
root 0ff4c24bd6 feat(server): extend InventionTimeline with full invention data and getSummaries
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:41:11 +00:00
root f362619c5f feat(shared): add InventionSummary type and socket events
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:40:00 +00:00
root 827b38c2c7 docs: add inventions panel implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:38:01 +00:00
root 89ae5d065b docs: add inventions panel design
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:35:51 +00:00
root 6d1f470ba5 docs: update completion status for Phases A-D.3
Mark all resource system phases (A, B, C, D.1-D.3) as complete in
the LLM integration roadmap and design docs. D.4 (structure
inspection) remains as future work.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:15:02 +00:00
root c7bf7c9ef4 feat(client): add Phase D UI integration (D.1-D.3)
- D.1: Inventory display in NPC info panel (two-column grid below stats)
- D.2: Activity labels for gather/craft/build/dropoff goals
- D.3: Gold color for invention events in feed, lightbulb icon in history

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:13:15 +00:00
root 9e4d2583f5 docs: add Phase D UI integration design (D.1-D.3)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:11:43 +00:00
root ed7113a34c docs: add Phase A, B, C implementation plans
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:03:03 +00:00
root e127aea842 test(systems): add invention integration test for end-to-end lifecycle
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 23:58:26 +00:00
root 857c7bc899 feat(game): wire inventionSystem and inventionTimeline into game loop
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 23:53:38 +00:00