From d3180b7d7877c77aee95dc1b37b64bab3ac4369a Mon Sep 17 00:00:00 2001 From: Bossiara13 <236771060+DmitryBykov-ISPO@users.noreply.github.com> Date: Fri, 15 May 2026 23:35:23 +0300 Subject: [PATCH] feat: GUI /memory page + disk/date_math/sleep_timer packs (10 new commands) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GUI: Memory management completes the management trio (/macros + /scheduler + /memory). Tauri commands (crates/jarvis-gui/src/tauri_commands/memory.rs) - memory_list → Vec - memory_remember(k, v) → persist new fact (or overwrite) - memory_forget(key) → delete by exact key - memory_search(q, limit) → substring search GUI /memory page (frontend/src/routes/memory/index.svelte) - Top: add-fact form (key + value inputs + "+Добавить" button) - Substring filter input for the list - Per-card: key + use_count badge + value (highlighted box) + timestamps + "Забыть" button with confirm() guard - Auto-sorted by recency (last_used_at desc) - Empty state shows voice-hint: 'скажи Jarvis-у "запомни что я люблю чай улун"' Header (frontend/src/components/Header.svelte) - New "Память" button between /scheduler and /settings. - i18n: header-memory in ru/en/ua FTL files. New voice packs resources/commands/disk/ (2 cmds) - disk.free "сколько свободно на диске" / "сколько места на диске C" PowerShell Get-PSDrive → speaks "Свободно X ГБ из Y, это N%" - disk.list "какие у меня диски" → "C 120 ГБ, D 300 ГБ, E 50 ГБ" resources/commands/date_math/ (2 cmds) - date.days_until "сколько дней до нового года" / "сколько до 8 марта" / "сколько до 15 марта" — recognises Russian months, holidays (Новый год, Рождество, 8 марта, 9 мая). Auto-rolls to next year if target already passed. Russian-grammar pluralisation (день/дня/дней). - date.day_of_week "какой сегодня день недели" — Zeller's congruence, maps to ru day name. resources/commands/sleep_timer/ (3 cmds) - sleep_timer.pause_in "выключи музыку через 30 минут" → scheduler one-shot lua action that fires media VK_MEDIA_PLAY_PAUSE via the existing media_keys helper. (Auto-generates _fire_pause.lua wrapper if missing.) - sleep_timer.shutdown_in "выключи компьютер через 1 час" → shutdown.exe /s /t . Caps at 24 hours. Speaks "Скажите 'отмени таймер' чтобы передумать." - sleep_timer.cancel "отмени таймер выключения" / "не выключай компьютер" → shutdown /a + scheduler.remove("sleep_timer_pause"), idempotent. Pack count: 64 → 67. Tests: 112/112 pass. Build: cargo build --release -p jarvis-gui green. --- crates/jarvis-core/src/i18n/locales/en.ftl | 3 +- crates/jarvis-core/src/i18n/locales/ru.ftl | 3 +- crates/jarvis-core/src/i18n/locales/ua.ftl | 3 +- crates/jarvis-gui/src/main.rs | 6 + crates/jarvis-gui/src/tauri_commands.rs | 6 +- .../jarvis-gui/src/tauri_commands/memory.rs | 45 ++++ frontend/src/components/Header.svelte | 4 + frontend/src/routes/memory/index.svelte | 249 ++++++++++++++++++ resources/commands/date_math/command.toml | 37 +++ resources/commands/date_math/day_of_week.lua | 21 ++ resources/commands/date_math/days_until.lua | 74 ++++++ resources/commands/disk/command.toml | 36 +++ resources/commands/disk/free.lua | 35 +++ resources/commands/disk/list.lua | 30 +++ resources/commands/sleep_timer/cancel.lua | 9 + resources/commands/sleep_timer/command.toml | 56 ++++ resources/commands/sleep_timer/pause_in.lua | 58 ++++ .../commands/sleep_timer/shutdown_in.lua | 46 ++++ 18 files changed, 717 insertions(+), 4 deletions(-) create mode 100644 crates/jarvis-gui/src/tauri_commands/memory.rs create mode 100644 frontend/src/routes/memory/index.svelte create mode 100644 resources/commands/date_math/command.toml create mode 100644 resources/commands/date_math/day_of_week.lua create mode 100644 resources/commands/date_math/days_until.lua create mode 100644 resources/commands/disk/command.toml create mode 100644 resources/commands/disk/free.lua create mode 100644 resources/commands/disk/list.lua create mode 100644 resources/commands/sleep_timer/cancel.lua create mode 100644 resources/commands/sleep_timer/command.toml create mode 100644 resources/commands/sleep_timer/pause_in.lua create mode 100644 resources/commands/sleep_timer/shutdown_in.lua diff --git a/crates/jarvis-core/src/i18n/locales/en.ftl b/crates/jarvis-core/src/i18n/locales/en.ftl index 2c6e690..7f5a15e 100644 --- a/crates/jarvis-core/src/i18n/locales/en.ftl +++ b/crates/jarvis-core/src/i18n/locales/en.ftl @@ -161,4 +161,5 @@ settings-profile = Profile # Header buttons header-macros = Macros -header-scheduler = Schedule \ No newline at end of file +header-scheduler = Schedule +header-memory = Memory \ No newline at end of file diff --git a/crates/jarvis-core/src/i18n/locales/ru.ftl b/crates/jarvis-core/src/i18n/locales/ru.ftl index 8a8d4a5..a0744d4 100644 --- a/crates/jarvis-core/src/i18n/locales/ru.ftl +++ b/crates/jarvis-core/src/i18n/locales/ru.ftl @@ -161,4 +161,5 @@ settings-profile = Профиль # Header buttons header-macros = Макросы -header-scheduler = Расписание \ No newline at end of file +header-scheduler = Расписание +header-memory = Память \ No newline at end of file diff --git a/crates/jarvis-core/src/i18n/locales/ua.ftl b/crates/jarvis-core/src/i18n/locales/ua.ftl index c40bf96..519d3c1 100644 --- a/crates/jarvis-core/src/i18n/locales/ua.ftl +++ b/crates/jarvis-core/src/i18n/locales/ua.ftl @@ -161,4 +161,5 @@ settings-profile = Профіль # Header buttons header-macros = Макроси -header-scheduler = Розклад \ No newline at end of file +header-scheduler = Розклад +header-memory = Пам'ять \ No newline at end of file diff --git a/crates/jarvis-gui/src/main.rs b/crates/jarvis-gui/src/main.rs index f495bdb..312a19a 100644 --- a/crates/jarvis-gui/src/main.rs +++ b/crates/jarvis-gui/src/main.rs @@ -122,6 +122,12 @@ fn main() { tauri_commands::scheduler_list, tauri_commands::scheduler_remove, tauri_commands::scheduler_clear, + + // Long-term memory facts + tauri_commands::memory_list, + tauri_commands::memory_remember, + tauri_commands::memory_forget, + tauri_commands::memory_search, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/crates/jarvis-gui/src/tauri_commands.rs b/crates/jarvis-gui/src/tauri_commands.rs index 44c7a06..c507333 100644 --- a/crates/jarvis-gui/src/tauri_commands.rs +++ b/crates/jarvis-gui/src/tauri_commands.rs @@ -49,4 +49,8 @@ pub use macros::*; // Scheduler tasks mod scheduler; -pub use scheduler::*; \ No newline at end of file +pub use scheduler::*; + +// Long-term memory facts +mod memory; +pub use memory::*; \ No newline at end of file diff --git a/crates/jarvis-gui/src/tauri_commands/memory.rs b/crates/jarvis-gui/src/tauri_commands/memory.rs new file mode 100644 index 0000000..16cd58a --- /dev/null +++ b/crates/jarvis-gui/src/tauri_commands/memory.rs @@ -0,0 +1,45 @@ +//! Tauri commands for the long-term memory store. + +use serde::Serialize; + +#[derive(Serialize)] +pub struct MemoryFact { + pub key: String, + pub value: String, + pub created_at: i64, + pub last_used_at: i64, + pub use_count: u64, +} + +#[tauri::command] +pub fn memory_list() -> Vec { + jarvis_core::long_term_memory::all().into_iter().map(|r| MemoryFact { + key: r.key, + value: r.value, + created_at: r.created_at, + last_used_at: r.last_used_at, + use_count: r.use_count, + }).collect() +} + +#[tauri::command] +pub fn memory_remember(key: String, value: String) -> Result<(), String> { + jarvis_core::long_term_memory::remember(&key, &value) +} + +#[tauri::command] +pub fn memory_forget(key: String) -> bool { + jarvis_core::long_term_memory::forget(&key) +} + +#[tauri::command] +pub fn memory_search(query: String, limit: Option) -> Vec { + jarvis_core::long_term_memory::search(&query, limit.unwrap_or(10)) + .into_iter().map(|r| MemoryFact { + key: r.key, + value: r.value, + created_at: r.created_at, + last_used_at: r.last_used_at, + use_count: r.use_count, + }).collect() +} diff --git a/frontend/src/components/Header.svelte b/frontend/src/components/Header.svelte index e00d9a4..c6a8161 100644 --- a/frontend/src/components/Header.svelte +++ b/frontend/src/components/Header.svelte @@ -80,6 +80,10 @@ {t('header-scheduler') || 'Расписание'} + + diff --git a/frontend/src/routes/memory/index.svelte b/frontend/src/routes/memory/index.svelte new file mode 100644 index 0000000..15cf678 --- /dev/null +++ b/frontend/src/routes/memory/index.svelte @@ -0,0 +1,249 @@ + + + + +

Память

+ + Долговременные факты о пользователе. LLM получает их в системном промпте автоматически, + когда фразой пересекаются. Хранятся в long_term_memory.json. + + + + +
+
+ + + +
+
+ + + + + + + +{#if error} + { error = "" }} + > + {error} + + +{/if} + +{#if loading} + +{:else if facts.length === 0} + + Память пустая. Добавь факт сверху или скажи Jarvis-у "запомни что я люблю чай улун". + +{:else if visible.length === 0} + + По фильтру ничего не найдено. Всего фактов: {facts.length}. + +{:else} +
+ {#each visible as fact} +
+
+ {fact.key} +
+ + {fact.use_count}× использований + +
+
+
+ {fact.value} +
+
+ Создан: {fmtDate(fact.created_at)} + Последний доступ: {fmtDate(fact.last_used_at)} +
+
+ +
+
+ {/each} +
+{/if} + + + + + + +