J.A.R.V.I.S-rust/crates/jarvis-core/src
Bossiara13 385bd5c8ce feat: persist LLM/TTS backend choice + reset/repeat context + quick-search + diagnostics
Closes the UX hole I created in 5c72450: voice-swap to Ollama used to vanish
after restart. Plus P0.3 (long-standing roadmap item) and two new packs.

Persistent backend choice (crates/jarvis-core/src/db/structs.rs)
  - Settings struct gains llm_backend + tts_backend fields (both String,
    "" / "auto" = follow env/auto-detect).
  - set("llm_backend", "groq"|"ollama"|"auto") validates input.
  - llm::init_global() reads DB first, then JARVIS_LLM env, then auto-detect.
  - llm::swap_to() now persists the choice via db::save_settings.
  - Voice swap "переключись на локальный" now survives restart.

Shared conversation history (P0.3, crates/jarvis-core/src/llm/mod.rs)
  - HISTORY: Lazy<RwLock<Option<ConversationHistory>>> singleton.
  - Helpers: init_history, history_push_user, history_push_assistant,
    history_snapshot, history_clear, history_pop_last_user, history_last_assistant.
  - llm_fallback migrated off its own Mutex<History> — now reads/writes shared.
  - ConversationHistory gains last_assistant() method.

New Lua APIs
  - jarvis.llm_reset()        → clear conversation turns (keeps system prompt).
  - jarvis.llm_last_reply()   → string or nil (last assistant message text).
  - jarvis.health()           → debug table {tts_backend, llm_backend, llm_model,
                                  active_profile, memory_facts, scheduled_tasks,
                                  language, voice, microphone, vosk_model,
                                  noise_suppression}. No secrets included.

New voice packs
  - resources/commands/llm_context/   (P0.3)
    * "сбрось контекст" / "забудь разговор"     → llm.reset
    * "повтори последнее" / "повтори ответ"     → llm.repeat (uses last_assistant)
  - resources/commands/quick_search/   (imba P1 item)
    * "найди в гугле <X>" / "загугли <X>"
    * Uses DuckDuckGo Instant Answer API (api.duckduckgo.com, no key required).
      Pulls AbstractText or RelatedTopics into LLM prompt; falls back to pure
      LLM knowledge if DDG returns nothing useful. Speaks 2-4 sentence answer.
  - resources/commands/diagnostics/
    * "диагностика" / "доложи о себе" / "статус"
    * Reads jarvis.health() and speaks a one-line summary. Useful when
      debugging — user can read out their current state for a bug report.

Build: cargo build --release -p jarvis-app -p jarvis-gui green.
Tests: 52/52 jarvis-core unit tests pass.
2026-05-15 16:25:28 +03:00
..
audio AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
audio_processing test: vad listening window timing 2026-04-23 11:08:02 +03:00
commands some fixes + gliner first implementation 2026-02-11 07:21:50 +05:00
config AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
db feat: persist LLM/TTS backend choice + reset/repeat context + quick-search + diagnostics 2026-05-15 16:25:28 +03:00
i18n/locales chore(gui): rebrand — strip TG/Boosty/Patreon/feedback-bot, keep CC BY-NC-SA attribution 2026-05-15 01:09:14 +03:00
intent AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
ipc feat(app): wire LlmClient into voice loop with trigger-prefix fallback 2026-04-23 02:16:02 +03:00
listener AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
llm feat: persist LLM/TTS backend choice + reset/repeat context + quick-search + diagnostics 2026-05-15 16:25:28 +03:00
lua feat: persist LLM/TTS backend choice + reset/repeat context + quick-search + diagnostics 2026-05-15 16:25:28 +03:00
models AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
recorder AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
slots AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
stt feat(core): vad-driven listening window state machine 2026-04-23 11:07:35 +03:00
time Tray options implementation + Voice system rewrite + build fixes 2026-01-07 23:29:46 +05:00
tts refactor: maintainability pass — dedup, central env config, cmd helpers, tests, ARCHITECTURE.md 2026-05-15 16:06:18 +03:00
voices Commands/voices multilanguage support + Ukranian vosk model added 2026-01-13 02:21:59 +05:00
audio.rs AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
audio_buffer.rs VAD fixes + some calibrations 2026-01-08 00:35:21 +05:00
audio_processing.rs AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
commands.rs test(commands): schema and Lua script validation for resources/commands/ 2026-05-15 00:55:01 +03:00
config.rs feat: TTS backend abstraction + 4 'imba' features + Lua packs 2026-05-15 15:32:44 +03:00
db.rs AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
i18n.rs AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
intent.rs AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
ipc.rs Tray options implementation + Voice system rewrite + build fixes 2026-01-07 23:29:46 +05:00
lib.rs refactor: maintainability pass — dedup, central env config, cmd helpers, tests, ARCHITECTURE.md 2026-05-15 16:06:18 +03:00
listener.rs AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
long_term_memory.rs refactor: maintainability pass — dedup, central env config, cmd helpers, tests, ARCHITECTURE.md 2026-05-15 16:06:18 +03:00
lua.rs basic Lua 5.4 implementation with few example commands 2026-01-17 05:46:38 +05:00
models.rs AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
profiles.rs refactor: maintainability pass — dedup, central env config, cmd helpers, tests, ARCHITECTURE.md 2026-05-15 16:06:18 +03:00
recorder.rs Improved wake-word & command detection, with dual mode 2026-02-08 06:37:39 +05:00
runtime_config.rs refactor: maintainability pass — dedup, central env config, cmd helpers, tests, ARCHITECTURE.md 2026-05-15 16:06:18 +03:00
scheduler.rs feat: hot-swap LLM backend + media keys + codebase Q&A + scheduler cancel-by-text + TTS pre-warm 2026-05-15 16:15:59 +03:00
slots.rs AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00
stt.rs feat(core): vad-driven listening window state machine 2026-04-23 11:07:35 +03:00
text_utils.rs fix(tts): sanitise text before SAPI so it stops reading "J.A.R.V.I.S." as "J точка A точка R точка..." 2026-05-15 14:48:42 +03:00
time.rs Tray options implementation + Voice system rewrite + build fixes 2026-01-07 23:29:46 +05:00
voices.rs AI models shared registry + Code cleanup + Better async handling + Some fixes, etc 2026-02-18 21:08:48 +05:00