Commit Graph

24 Commits

Author SHA1 Message Date
Dejvino
6b277d725d LLM tests 2026-06-30 21:44:57 +02:00
Dejvino
6229e2e8c4 Cleanup and simplification 2026-06-30 21:18:35 +02:00
Dejvino
66da60225a Improve llm calling 2026-06-30 20:40:40 +02:00
Dejvino
545d3bcac0 More refactors 2026-06-30 20:03:53 +02:00
Dejvino
64b6416929 Code split to allow small LLM to work on it 2026-06-30 18:47:44 +02:00
Dejvino
91b1b35cfa Add more logging. Selectable LLM strategy. 2026-06-29 22:59:45 +02:00
Dejvino
25fb5fd729 Settings store 2026-06-28 18:53:33 +02:00
Dejvino
c0e8fd8522 Changes printed out explicitly 2026-06-28 18:40:52 +02:00
Dejvino
5b93040f73 LLM retries and validations 2026-06-28 18:08:58 +02:00
Dejvino
a7e6d5540f Changes block from prose llm 2026-06-28 17:49:43 +02:00
Dejvino
e74dd07699 Simpler tool calls with examples 2026-06-28 16:30:36 +02:00
Dejvino
84b53cfd0c Clean log and prompt pollution 2026-06-28 16:21:21 +02:00
Dejvino
12a8398f9f Dumb down the turn processing for a smaller LLM 2026-06-28 16:17:23 +02:00
Dejvino
0733d178d0 Add all messages into context, limit output token count 2026-06-28 14:07:41 +02:00
Dejvino
277c9cfdb2 Prompt tweaks 2026-06-26 06:49:32 +02:00
Dejvino
18ae3be428 Tweaks of gitignore, LLM block strip, config template 2026-06-25 23:07:19 +02:00
Dejvino
52f590d432 Update engine.py with AMBIENCE_OPTIONS_PATH and AUDIO_DIR, and adjust related functions 2026-06-25 22:15:06 +02:00
Dejvino
d78aad6ce4 context-bounded tool loop, debug pane, ambience mute, finalize_turn fence fix 2026-06-25 21:21:41 +02:00
Dejvino
326c8b7ba8 fix journal_update bugs, persist last prompt across restarts
- Coerce string add/done to list in journal_update tool
- Rewrite _update_journal with section-based parsing (no broken index tracking)
- Add duplicate prevention, blank line collapsing
- Save last DM prompt to session/last_prompt.md so game resumes
  from last scene on restart instead of regenerating
2026-06-25 19:53:57 +02:00
Dejvino
35c04bdbca add journal/quest tracking guidance to system prompt 2026-06-25 19:33:23 +02:00
Dejvino
8c06fd1be7 reject character/world updates that are <70% of original size
Adds _validate_update_size() safeguard that skips writing if the
LLM returns a fragment instead of the full file — warns on stderr.
2026-06-25 19:31:58 +02:00
Dejvino
4c968f8096 fix llm config for ramalama, add safeguards, spinner animation
- Fix last_narrative -> last_prompt bug in generate() and generate_stream()
- Add **kwargs guard to build_user_message() to catch wrong param names
- Extract _set_llm_env() helper that always sets API key (fallback placeholder)
- Add 30s timeout to all litellm.completion() calls
- Update config model to openai/deepseek-r1 for ramalama
- Replace shifting dots spinner with fixed-character shape morph
2026-06-25 19:21:55 +02:00
Dejvino
d265dfc7f7 DM tool loop, player roll modal, free-form input
- Add tool-use loop in generate_with_tools(): LLM can call read_file,
  roll, player_roll, and think tools via tool fenced blocks before
  producing the final json response. Tool results fed back for
  multi-round reasoning.
- Add player_roll tool: shows a modal overlay asking the player to
  physically roll dice and type the result. Blocks the worker thread
  via threading.Event until the player responds.
- Add RollModal Screen with dice label, reason, input, and submit.
- Every tool call updates status bar with a specific DM action
  message (e.g. "DM is rolling dice", "DM is reading the character
  sheet") instead of the generic "weaving the narrative".
  The thinking-dot animation uses the last-reported action as its base.
- Replace all user-facing "LLM" references with "DM".
- Remove predefined choices: no more choice buttons or choice
  container. Player types freely. System prompt says "never present
  predefined choices" and all instruction templates say "let the
  player decide".
- Add book story context to system prompt — last 3 turns from
  book.md injected as "Recent Story" section.
- Fix build_user_message: detects existing book content; if story
  exists, sends "continue from where it left off" instead of
  "establish the opening scene".
- Improve parse_response: add JSON-only fallback when no json
  fenced block is found.
2026-06-25 15:14:35 +02:00
Dejvino
4b9078d41f TUI now owns the full game loop with embedded LLM engine
The game is now self-contained: run.sh starts the TUI, which calls the
LLM directly via engine.py. No external agent (OpenCode) needed.

- tools/engine.py: Game engine with prompt builder, litellm client,
  response parser (JSON block extraction), and state persistence
- tools/run.py: Refactored TUI with PLAY/CHAR/LOG/BOOK tabs. PLAY tab
  has streaming narrative pane, dynamic choice buttons, and text input.
  Game loop: scene -> input -> resolve -> archive -> apply -> scene
- session/config.json: LLM provider configuration (model, api_key, etc.)
- AGENTS.md: Updated to document the new architecture
- tools/__init__.py: Package marker for clean imports
- session/turn_description.md, turn_reaction.md: Deprecated - no longer
  needed now that the TUI drives the game loop internally
2026-06-25 12:12:04 +02:00