J.A.R.V.I.S-rust/resources/commands/translate/translate.lua

139 lines
5.2 KiB
Lua
Raw Permalink Normal View History

feat(commands): tier-1 — translate, math, theme toggle, project opener, sound panel Five more portable Lua command packs. Bumps the total from 16 to 21 packs. cargo test -p jarvis-core --lib commands::tests still 3/3. translate/ — translate.lua. Picks the target language from triggers like "переведи на английский" / "translate to russian"; falls back to English when only "переведи X" is heard. Sends to Groq with a strict "translation only" system prompt at temp 0.3. Drops the result into the clipboard, fires a notify, and speaks via PowerShell SAPI in the matching ISO voice (ru-RU / uk-UA / en-US / de-DE etc.) so a German translation actually sounds German. math/ — math.lua. Strips the trigger ("посчитай" / "calculate" / "сколько будет" / "what is" / ...), sends the remainder to Groq with temp=0.0 and max_tokens=64, asking ONLY for the numeric result. If the model replies "нет" (the system-prompt sentinel for non-math), plays not_found instead of speaking nonsense. Otherwise speaks "Получилось X" via SAPI. theme/ — set.lua dispatched by command_id (theme_dark / theme_light). Flips AppsUseLightTheme + SystemUsesLightTheme under HKCU\...\Themes\Personalize via Set-ItemProperty. No reboot needed, Windows shell re-themes immediately. projects/ — open.lua + list.lua. Reads/creates %USERPROFILE%\Documents\jarvis-projects.json (a flat [{"name": ..., "path": ...}] list). open.lua strips the trigger, exact-matches then substring-matches the project name, opens the path in VS Code if `code.cmd` is on PATH, otherwise in Explorer. First call creates a sample config with jarvis-rust / jarvis-python / dietpi entries pointing under USERPROFILE so it works on any machine. list.lua just notifies the configured project names. sound_panel/ — open.lua. Two-liner: rundll32 mmsys.cpl,,1 (Recording tab). Useful both as a standalone "открой настройки звука" and as the place to fix the mic-disabled state that prevents jarvis-app from starting. Portability: USERPROFILE / SystemDrive / PATH lookup throughout.
2026-05-15 12:06:30 +03:00
local lang = jarvis.context.language
local phrase = (jarvis.context.phrase or ""):lower()
local target_languages = {
feat: Wave 5 — sysinfo speaks, smart reminders, outlook COM, time tracker, WOL, conversation tools Voice sysinfo overhaul (6 scripts: battery/cpu/ram/disk/time/all): - Now SPEAK the result via jarvis.cmd.ok instead of notify-only. Toast still fires for visual reference, but real Jarvis tells you out loud. - `all` joins lines with commas so TTS doesn't over-pause on linebreaks. Smart reminders (`reminders/set.lua` rewrite): - Was: detached `Start-Sleep` PowerShell subprocesses that died on jarvis-app restart and spawned a hidden process per timer. - Now: routes through `jarvis.scheduler.add(... type=speak ...)`. Persists to schedule.json, survives restart, no zombie processes. Trade-off: sub-minute timers round up to 1 min (rare in voice UX). - Drops UA triggers from earlier UA-removal sweep. Translation polish (`translate/translate.lua` + `clipboard.lua`): - Drops UA target language; adds Italian, Polish, Turkish, French ru triggers + English target detectors. - `language_iso()` helper picks the SAPI voice locale for the TARGET language (German translation → German SAPI voice if installed). LLM system prompt (config.rs): - New LLM_SYSTEM_PROMPT_EN counterpart. Both languages now mention the assistant's tooling (memory / scheduler / profiles / macros / vision / clipboard) so the LLM knows it can DO things, not suggest the user install something. - `get_llm_system_prompt(lang)` picks EN/RU. Conversation pack (NEW `conversation/`): - 2 commands. `conversation.summary` ("о чём мы говорили") pulls the last 12 turns from persisted history, asks LLM for a 1-3 sentence recap in Jarvis tone. Falls back gracefully when offline. - `conversation.repeat` ("повтори") re-speaks the last assistant message. - New Lua API `jarvis.llm_history()` returns array of {role, content} tables, excluding the system prompt. WOL pack (NEW `wol/`): - Voice "разбуди сервер" / "wake server" fires a magic packet at a MAC stored in long-term memory under `wol_<alias>` (default alias "server"). - Setup via voice: "запомни wol_server AA:BB:CC:DD:EE:FF". Falls back to `JARVIS_WOL_TARGET` env if memory empty. Handles every standard MAC format (colons / dashes / dots / bare). Broadcast on UDP 9 via PowerShell System.Net.Sockets.UdpClient. Outlook COM pack (NEW `outlook/`, via subagent): - 4 commands: unread_count, latest, send_clipboard, summarize_inbox. - PowerShell COM bridge `_outlook.ps1` with tab-delimited line protocol. - summarize_inbox calls LLM for a one-paragraph summary. Graceful failure when Outlook isn't running. Time tracker pack (NEW `time_tracker/`, via subagent): - 5 commands: start, stop, today, week, reset. - Persists via `jarvis.state` (structured object: current_session_start + sessions array of {start, end}). - Local-calendar "today" boundary, full Russian pluralisation (час/часа/часов, минута/минуты/минут, сессия/сессии/сессий). Tests: 139 rust (no regression), 81 python (60 → 81, +14 time_tracker +7 outlook). Release build green for jarvis-app and jarvis-cli. Pack count: 88 → 92 rust packs.
2026-05-16 14:34:29 +03:00
["английский"] = "English", ["english"] = "English",
["русский"] = "Russian", ["russian"] = "Russian",
["немецкий"] = "German", ["german"] = "German",
["французский"]= "French", ["french"] = "French",
["испанский"] = "Spanish", ["spanish"] = "Spanish",
["итальянский"]= "Italian", ["italian"] = "Italian",
["китайский"] = "Chinese", ["chinese"] = "Chinese",
["японский"] = "Japanese", ["japanese"] = "Japanese",
["польский"] = "Polish", ["polish"] = "Polish",
["турецкий"] = "Turkish", ["turkish"] = "Turkish",
feat(commands): tier-1 — translate, math, theme toggle, project opener, sound panel Five more portable Lua command packs. Bumps the total from 16 to 21 packs. cargo test -p jarvis-core --lib commands::tests still 3/3. translate/ — translate.lua. Picks the target language from triggers like "переведи на английский" / "translate to russian"; falls back to English when only "переведи X" is heard. Sends to Groq with a strict "translation only" system prompt at temp 0.3. Drops the result into the clipboard, fires a notify, and speaks via PowerShell SAPI in the matching ISO voice (ru-RU / uk-UA / en-US / de-DE etc.) so a German translation actually sounds German. math/ — math.lua. Strips the trigger ("посчитай" / "calculate" / "сколько будет" / "what is" / ...), sends the remainder to Groq with temp=0.0 and max_tokens=64, asking ONLY for the numeric result. If the model replies "нет" (the system-prompt sentinel for non-math), plays not_found instead of speaking nonsense. Otherwise speaks "Получилось X" via SAPI. theme/ — set.lua dispatched by command_id (theme_dark / theme_light). Flips AppsUseLightTheme + SystemUsesLightTheme under HKCU\...\Themes\Personalize via Set-ItemProperty. No reboot needed, Windows shell re-themes immediately. projects/ — open.lua + list.lua. Reads/creates %USERPROFILE%\Documents\jarvis-projects.json (a flat [{"name": ..., "path": ...}] list). open.lua strips the trigger, exact-matches then substring-matches the project name, opens the path in VS Code if `code.cmd` is on PATH, otherwise in Explorer. First call creates a sample config with jarvis-rust / jarvis-python / dietpi entries pointing under USERPROFILE so it works on any machine. list.lua just notifies the configured project names. sound_panel/ — open.lua. Two-liner: rundll32 mmsys.cpl,,1 (Recording tab). Useful both as a standalone "открой настройки звука" and as the place to fix the mic-disabled state that prevents jarvis-app from starting. Portability: USERPROFILE / SystemDrive / PATH lookup throughout.
2026-05-15 12:06:30 +03:00
}
local triggers_with_lang = {
feat: Wave 5 — sysinfo speaks, smart reminders, outlook COM, time tracker, WOL, conversation tools Voice sysinfo overhaul (6 scripts: battery/cpu/ram/disk/time/all): - Now SPEAK the result via jarvis.cmd.ok instead of notify-only. Toast still fires for visual reference, but real Jarvis tells you out loud. - `all` joins lines with commas so TTS doesn't over-pause on linebreaks. Smart reminders (`reminders/set.lua` rewrite): - Was: detached `Start-Sleep` PowerShell subprocesses that died on jarvis-app restart and spawned a hidden process per timer. - Now: routes through `jarvis.scheduler.add(... type=speak ...)`. Persists to schedule.json, survives restart, no zombie processes. Trade-off: sub-minute timers round up to 1 min (rare in voice UX). - Drops UA triggers from earlier UA-removal sweep. Translation polish (`translate/translate.lua` + `clipboard.lua`): - Drops UA target language; adds Italian, Polish, Turkish, French ru triggers + English target detectors. - `language_iso()` helper picks the SAPI voice locale for the TARGET language (German translation → German SAPI voice if installed). LLM system prompt (config.rs): - New LLM_SYSTEM_PROMPT_EN counterpart. Both languages now mention the assistant's tooling (memory / scheduler / profiles / macros / vision / clipboard) so the LLM knows it can DO things, not suggest the user install something. - `get_llm_system_prompt(lang)` picks EN/RU. Conversation pack (NEW `conversation/`): - 2 commands. `conversation.summary` ("о чём мы говорили") pulls the last 12 turns from persisted history, asks LLM for a 1-3 sentence recap in Jarvis tone. Falls back gracefully when offline. - `conversation.repeat` ("повтори") re-speaks the last assistant message. - New Lua API `jarvis.llm_history()` returns array of {role, content} tables, excluding the system prompt. WOL pack (NEW `wol/`): - Voice "разбуди сервер" / "wake server" fires a magic packet at a MAC stored in long-term memory under `wol_<alias>` (default alias "server"). - Setup via voice: "запомни wol_server AA:BB:CC:DD:EE:FF". Falls back to `JARVIS_WOL_TARGET` env if memory empty. Handles every standard MAC format (colons / dashes / dots / bare). Broadcast on UDP 9 via PowerShell System.Net.Sockets.UdpClient. Outlook COM pack (NEW `outlook/`, via subagent): - 4 commands: unread_count, latest, send_clipboard, summarize_inbox. - PowerShell COM bridge `_outlook.ps1` with tab-delimited line protocol. - summarize_inbox calls LLM for a one-paragraph summary. Graceful failure when Outlook isn't running. Time tracker pack (NEW `time_tracker/`, via subagent): - 5 commands: start, stop, today, week, reset. - Persists via `jarvis.state` (structured object: current_session_start + sessions array of {start, end}). - Local-calendar "today" boundary, full Russian pluralisation (час/часа/часов, минута/минуты/минут, сессия/сессии/сессий). Tests: 139 rust (no regression), 81 python (60 → 81, +14 time_tracker +7 outlook). Release build green for jarvis-app and jarvis-cli. Pack count: 88 → 92 rust packs.
2026-05-16 14:34:29 +03:00
"переведи на ", "translate to ", "how to say in ",
feat(commands): tier-1 — translate, math, theme toggle, project opener, sound panel Five more portable Lua command packs. Bumps the total from 16 to 21 packs. cargo test -p jarvis-core --lib commands::tests still 3/3. translate/ — translate.lua. Picks the target language from triggers like "переведи на английский" / "translate to russian"; falls back to English when only "переведи X" is heard. Sends to Groq with a strict "translation only" system prompt at temp 0.3. Drops the result into the clipboard, fires a notify, and speaks via PowerShell SAPI in the matching ISO voice (ru-RU / uk-UA / en-US / de-DE etc.) so a German translation actually sounds German. math/ — math.lua. Strips the trigger ("посчитай" / "calculate" / "сколько будет" / "what is" / ...), sends the remainder to Groq with temp=0.0 and max_tokens=64, asking ONLY for the numeric result. If the model replies "нет" (the system-prompt sentinel for non-math), plays not_found instead of speaking nonsense. Otherwise speaks "Получилось X" via SAPI. theme/ — set.lua dispatched by command_id (theme_dark / theme_light). Flips AppsUseLightTheme + SystemUsesLightTheme under HKCU\...\Themes\Personalize via Set-ItemProperty. No reboot needed, Windows shell re-themes immediately. projects/ — open.lua + list.lua. Reads/creates %USERPROFILE%\Documents\jarvis-projects.json (a flat [{"name": ..., "path": ...}] list). open.lua strips the trigger, exact-matches then substring-matches the project name, opens the path in VS Code if `code.cmd` is on PATH, otherwise in Explorer. First call creates a sample config with jarvis-rust / jarvis-python / dietpi entries pointing under USERPROFILE so it works on any machine. list.lua just notifies the configured project names. sound_panel/ — open.lua. Two-liner: rundll32 mmsys.cpl,,1 (Recording tab). Useful both as a standalone "открой настройки звука" and as the place to fix the mic-disabled state that prevents jarvis-app from starting. Portability: USERPROFILE / SystemDrive / PATH lookup throughout.
2026-05-15 12:06:30 +03:00
}
local generic_triggers = {
feat: Wave 5 — sysinfo speaks, smart reminders, outlook COM, time tracker, WOL, conversation tools Voice sysinfo overhaul (6 scripts: battery/cpu/ram/disk/time/all): - Now SPEAK the result via jarvis.cmd.ok instead of notify-only. Toast still fires for visual reference, but real Jarvis tells you out loud. - `all` joins lines with commas so TTS doesn't over-pause on linebreaks. Smart reminders (`reminders/set.lua` rewrite): - Was: detached `Start-Sleep` PowerShell subprocesses that died on jarvis-app restart and spawned a hidden process per timer. - Now: routes through `jarvis.scheduler.add(... type=speak ...)`. Persists to schedule.json, survives restart, no zombie processes. Trade-off: sub-minute timers round up to 1 min (rare in voice UX). - Drops UA triggers from earlier UA-removal sweep. Translation polish (`translate/translate.lua` + `clipboard.lua`): - Drops UA target language; adds Italian, Polish, Turkish, French ru triggers + English target detectors. - `language_iso()` helper picks the SAPI voice locale for the TARGET language (German translation → German SAPI voice if installed). LLM system prompt (config.rs): - New LLM_SYSTEM_PROMPT_EN counterpart. Both languages now mention the assistant's tooling (memory / scheduler / profiles / macros / vision / clipboard) so the LLM knows it can DO things, not suggest the user install something. - `get_llm_system_prompt(lang)` picks EN/RU. Conversation pack (NEW `conversation/`): - 2 commands. `conversation.summary` ("о чём мы говорили") pulls the last 12 turns from persisted history, asks LLM for a 1-3 sentence recap in Jarvis tone. Falls back gracefully when offline. - `conversation.repeat` ("повтори") re-speaks the last assistant message. - New Lua API `jarvis.llm_history()` returns array of {role, content} tables, excluding the system prompt. WOL pack (NEW `wol/`): - Voice "разбуди сервер" / "wake server" fires a magic packet at a MAC stored in long-term memory under `wol_<alias>` (default alias "server"). - Setup via voice: "запомни wol_server AA:BB:CC:DD:EE:FF". Falls back to `JARVIS_WOL_TARGET` env if memory empty. Handles every standard MAC format (colons / dashes / dots / bare). Broadcast on UDP 9 via PowerShell System.Net.Sockets.UdpClient. Outlook COM pack (NEW `outlook/`, via subagent): - 4 commands: unread_count, latest, send_clipboard, summarize_inbox. - PowerShell COM bridge `_outlook.ps1` with tab-delimited line protocol. - summarize_inbox calls LLM for a one-paragraph summary. Graceful failure when Outlook isn't running. Time tracker pack (NEW `time_tracker/`, via subagent): - 5 commands: start, stop, today, week, reset. - Persists via `jarvis.state` (structured object: current_session_start + sessions array of {start, end}). - Local-calendar "today" boundary, full Russian pluralisation (час/часа/часов, минута/минуты/минут, сессия/сессии/сессий). Tests: 139 rust (no regression), 81 python (60 → 81, +14 time_tracker +7 outlook). Release build green for jarvis-app and jarvis-cli. Pack count: 88 → 92 rust packs.
2026-05-16 14:34:29 +03:00
"переведи", "translate", "как по ", "how to say",
feat(commands): tier-1 — translate, math, theme toggle, project opener, sound panel Five more portable Lua command packs. Bumps the total from 16 to 21 packs. cargo test -p jarvis-core --lib commands::tests still 3/3. translate/ — translate.lua. Picks the target language from triggers like "переведи на английский" / "translate to russian"; falls back to English when only "переведи X" is heard. Sends to Groq with a strict "translation only" system prompt at temp 0.3. Drops the result into the clipboard, fires a notify, and speaks via PowerShell SAPI in the matching ISO voice (ru-RU / uk-UA / en-US / de-DE etc.) so a German translation actually sounds German. math/ — math.lua. Strips the trigger ("посчитай" / "calculate" / "сколько будет" / "what is" / ...), sends the remainder to Groq with temp=0.0 and max_tokens=64, asking ONLY for the numeric result. If the model replies "нет" (the system-prompt sentinel for non-math), plays not_found instead of speaking nonsense. Otherwise speaks "Получилось X" via SAPI. theme/ — set.lua dispatched by command_id (theme_dark / theme_light). Flips AppsUseLightTheme + SystemUsesLightTheme under HKCU\...\Themes\Personalize via Set-ItemProperty. No reboot needed, Windows shell re-themes immediately. projects/ — open.lua + list.lua. Reads/creates %USERPROFILE%\Documents\jarvis-projects.json (a flat [{"name": ..., "path": ...}] list). open.lua strips the trigger, exact-matches then substring-matches the project name, opens the path in VS Code if `code.cmd` is on PATH, otherwise in Explorer. First call creates a sample config with jarvis-rust / jarvis-python / dietpi entries pointing under USERPROFILE so it works on any machine. list.lua just notifies the configured project names. sound_panel/ — open.lua. Two-liner: rundll32 mmsys.cpl,,1 (Recording tab). Useful both as a standalone "открой настройки звука" and as the place to fix the mic-disabled state that prevents jarvis-app from starting. Portability: USERPROFILE / SystemDrive / PATH lookup throughout.
2026-05-15 12:06:30 +03:00
}
local target = nil
local body = phrase
for _, t in ipairs(triggers_with_lang) do
local s, e = string.find(body, t, 1, true)
if s == 1 then
local rest = body:sub(e + 1)
local first_word = rest:match("^(%S+)")
if first_word and target_languages[first_word] then
target = target_languages[first_word]
body = rest:sub(#first_word + 1)
break
end
end
end
if not target then
for _, t in ipairs(generic_triggers) do
local s, e = string.find(body, t, 1, true)
if s == 1 then
body = body:sub(e + 1)
break
end
end
end
body = body:gsub("^%s+", ""):gsub("%s+$", "")
if body == "" then
jarvis.system.notify(
"Translate",
lang == "ru" and "Что переводить?" or "What to translate?"
)
jarvis.audio.play_error()
return { chain = false }
end
local token = jarvis.system.env("GROQ_TOKEN")
if not token or token == "" then
jarvis.system.notify("Translate", "GROQ_TOKEN не задан")
jarvis.audio.play_error()
return { chain = false }
end
local base = jarvis.system.env("GROQ_BASE_URL"); if not base or base == "" then base = "https://api.groq.com/openai/v1" end
local model = jarvis.system.env("GROQ_MODEL"); if not model or model == "" then model = "llama-3.3-70b-versatile" end
local target_label = target or (lang == "ru" and "English" or "Russian")
local sys = string.format(
"You are a professional translator. Translate the user message into %s. "
.. "Output ONLY the translation, no explanations, no quotes, no prefix. "
.. "Preserve idioms and tone.",
target_label
)
jarvis.log("info", "translate -> " .. target_label .. " : " .. body)
local payload = {
model = model,
messages = {
{ role = "system", content = sys },
{ role = "user", content = body },
},
max_tokens = 512,
temperature = 0.3,
}
local res = jarvis.http.post_json(base .. "/chat/completions", payload, { Authorization = "Bearer " .. token })
if not res.ok then
jarvis.log("error", "translate api failed: " .. tostring(res.status) .. " " .. tostring(res.body):sub(1, 200))
jarvis.system.notify("Translate", "Ошибка API")
jarvis.audio.play_error()
return { chain = false }
end
local body_resp = res.body or ""
local content = body_resp:match('"content"%s*:%s*"(.-[^\\])"')
if not content then
jarvis.system.notify("Translate", "Не смог распарсить ответ")
jarvis.audio.play_error()
return { chain = false }
end
content = content:gsub('\\n', '\n'):gsub('\\"', '"'):gsub('\\\\', '\\'):gsub('\\t', '\t')
content = content:gsub("^%s+", ""):gsub("%s+$", "")
jarvis.system.clipboard.set(content)
jarvis.system.notify(target_label, content:sub(1, 200))
jarvis.log("info", "translation: " .. content)
feat: Wave 5 — sysinfo speaks, smart reminders, outlook COM, time tracker, WOL, conversation tools Voice sysinfo overhaul (6 scripts: battery/cpu/ram/disk/time/all): - Now SPEAK the result via jarvis.cmd.ok instead of notify-only. Toast still fires for visual reference, but real Jarvis tells you out loud. - `all` joins lines with commas so TTS doesn't over-pause on linebreaks. Smart reminders (`reminders/set.lua` rewrite): - Was: detached `Start-Sleep` PowerShell subprocesses that died on jarvis-app restart and spawned a hidden process per timer. - Now: routes through `jarvis.scheduler.add(... type=speak ...)`. Persists to schedule.json, survives restart, no zombie processes. Trade-off: sub-minute timers round up to 1 min (rare in voice UX). - Drops UA triggers from earlier UA-removal sweep. Translation polish (`translate/translate.lua` + `clipboard.lua`): - Drops UA target language; adds Italian, Polish, Turkish, French ru triggers + English target detectors. - `language_iso()` helper picks the SAPI voice locale for the TARGET language (German translation → German SAPI voice if installed). LLM system prompt (config.rs): - New LLM_SYSTEM_PROMPT_EN counterpart. Both languages now mention the assistant's tooling (memory / scheduler / profiles / macros / vision / clipboard) so the LLM knows it can DO things, not suggest the user install something. - `get_llm_system_prompt(lang)` picks EN/RU. Conversation pack (NEW `conversation/`): - 2 commands. `conversation.summary` ("о чём мы говорили") pulls the last 12 turns from persisted history, asks LLM for a 1-3 sentence recap in Jarvis tone. Falls back gracefully when offline. - `conversation.repeat` ("повтори") re-speaks the last assistant message. - New Lua API `jarvis.llm_history()` returns array of {role, content} tables, excluding the system prompt. WOL pack (NEW `wol/`): - Voice "разбуди сервер" / "wake server" fires a magic packet at a MAC stored in long-term memory under `wol_<alias>` (default alias "server"). - Setup via voice: "запомни wol_server AA:BB:CC:DD:EE:FF". Falls back to `JARVIS_WOL_TARGET` env if memory empty. Handles every standard MAC format (colons / dashes / dots / bare). Broadcast on UDP 9 via PowerShell System.Net.Sockets.UdpClient. Outlook COM pack (NEW `outlook/`, via subagent): - 4 commands: unread_count, latest, send_clipboard, summarize_inbox. - PowerShell COM bridge `_outlook.ps1` with tab-delimited line protocol. - summarize_inbox calls LLM for a one-paragraph summary. Graceful failure when Outlook isn't running. Time tracker pack (NEW `time_tracker/`, via subagent): - 5 commands: start, stop, today, week, reset. - Persists via `jarvis.state` (structured object: current_session_start + sessions array of {start, end}). - Local-calendar "today" boundary, full Russian pluralisation (час/часа/часов, минута/минуты/минут, сессия/сессии/сессий). Tests: 139 rust (no regression), 81 python (60 → 81, +14 time_tracker +7 outlook). Release build green for jarvis-app and jarvis-cli. Pack count: 88 → 92 rust packs.
2026-05-16 14:34:29 +03:00
-- Speak the translation in the TARGET language's voice when possible, so a
-- French translation comes out with a French SAPI voice if installed. Falls
-- back silently to the default voice if there's no matching locale on the box.
local function language_iso(label)
if label == "Russian" then return "ru" end
if label == "German" then return "de" end
if label == "French" then return "fr" end
if label == "Spanish" then return "es" end
if label == "Italian" then return "it" end
if label == "Chinese" then return "zh" end
if label == "Japanese" then return "ja" end
if label == "Polish" then return "pl" end
if label == "Turkish" then return "tr" end
return "en"
end
feat(commands): tier-1 — translate, math, theme toggle, project opener, sound panel Five more portable Lua command packs. Bumps the total from 16 to 21 packs. cargo test -p jarvis-core --lib commands::tests still 3/3. translate/ — translate.lua. Picks the target language from triggers like "переведи на английский" / "translate to russian"; falls back to English when only "переведи X" is heard. Sends to Groq with a strict "translation only" system prompt at temp 0.3. Drops the result into the clipboard, fires a notify, and speaks via PowerShell SAPI in the matching ISO voice (ru-RU / uk-UA / en-US / de-DE etc.) so a German translation actually sounds German. math/ — math.lua. Strips the trigger ("посчитай" / "calculate" / "сколько будет" / "what is" / ...), sends the remainder to Groq with temp=0.0 and max_tokens=64, asking ONLY for the numeric result. If the model replies "нет" (the system-prompt sentinel for non-math), plays not_found instead of speaking nonsense. Otherwise speaks "Получилось X" via SAPI. theme/ — set.lua dispatched by command_id (theme_dark / theme_light). Flips AppsUseLightTheme + SystemUsesLightTheme under HKCU\...\Themes\Personalize via Set-ItemProperty. No reboot needed, Windows shell re-themes immediately. projects/ — open.lua + list.lua. Reads/creates %USERPROFILE%\Documents\jarvis-projects.json (a flat [{"name": ..., "path": ...}] list). open.lua strips the trigger, exact-matches then substring-matches the project name, opens the path in VS Code if `code.cmd` is on PATH, otherwise in Explorer. First call creates a sample config with jarvis-rust / jarvis-python / dietpi entries pointing under USERPROFILE so it works on any machine. list.lua just notifies the configured project names. sound_panel/ — open.lua. Two-liner: rundll32 mmsys.cpl,,1 (Recording tab). Useful both as a standalone "открой настройки звука" and as the place to fix the mic-disabled state that prevents jarvis-app from starting. Portability: USERPROFILE / SystemDrive / PATH lookup throughout.
2026-05-15 12:06:30 +03:00
local sapi_text = content:gsub("'", "''"):gsub("\r?\n", " ")
local ps = string.format(
[[Add-Type -AssemblyName System.Speech; $s = New-Object System.Speech.Synthesis.SpeechSynthesizer; $iso='%s'; foreach ($v in $s.GetInstalledVoices()) { if ($v.VoiceInfo.Culture.TwoLetterISOLanguageName -eq $iso) { try { $s.SelectVoice($v.VoiceInfo.Name); break } catch {} } } $s.Speak('%s')]],
feat: Wave 5 — sysinfo speaks, smart reminders, outlook COM, time tracker, WOL, conversation tools Voice sysinfo overhaul (6 scripts: battery/cpu/ram/disk/time/all): - Now SPEAK the result via jarvis.cmd.ok instead of notify-only. Toast still fires for visual reference, but real Jarvis tells you out loud. - `all` joins lines with commas so TTS doesn't over-pause on linebreaks. Smart reminders (`reminders/set.lua` rewrite): - Was: detached `Start-Sleep` PowerShell subprocesses that died on jarvis-app restart and spawned a hidden process per timer. - Now: routes through `jarvis.scheduler.add(... type=speak ...)`. Persists to schedule.json, survives restart, no zombie processes. Trade-off: sub-minute timers round up to 1 min (rare in voice UX). - Drops UA triggers from earlier UA-removal sweep. Translation polish (`translate/translate.lua` + `clipboard.lua`): - Drops UA target language; adds Italian, Polish, Turkish, French ru triggers + English target detectors. - `language_iso()` helper picks the SAPI voice locale for the TARGET language (German translation → German SAPI voice if installed). LLM system prompt (config.rs): - New LLM_SYSTEM_PROMPT_EN counterpart. Both languages now mention the assistant's tooling (memory / scheduler / profiles / macros / vision / clipboard) so the LLM knows it can DO things, not suggest the user install something. - `get_llm_system_prompt(lang)` picks EN/RU. Conversation pack (NEW `conversation/`): - 2 commands. `conversation.summary` ("о чём мы говорили") pulls the last 12 turns from persisted history, asks LLM for a 1-3 sentence recap in Jarvis tone. Falls back gracefully when offline. - `conversation.repeat` ("повтори") re-speaks the last assistant message. - New Lua API `jarvis.llm_history()` returns array of {role, content} tables, excluding the system prompt. WOL pack (NEW `wol/`): - Voice "разбуди сервер" / "wake server" fires a magic packet at a MAC stored in long-term memory under `wol_<alias>` (default alias "server"). - Setup via voice: "запомни wol_server AA:BB:CC:DD:EE:FF". Falls back to `JARVIS_WOL_TARGET` env if memory empty. Handles every standard MAC format (colons / dashes / dots / bare). Broadcast on UDP 9 via PowerShell System.Net.Sockets.UdpClient. Outlook COM pack (NEW `outlook/`, via subagent): - 4 commands: unread_count, latest, send_clipboard, summarize_inbox. - PowerShell COM bridge `_outlook.ps1` with tab-delimited line protocol. - summarize_inbox calls LLM for a one-paragraph summary. Graceful failure when Outlook isn't running. Time tracker pack (NEW `time_tracker/`, via subagent): - 5 commands: start, stop, today, week, reset. - Persists via `jarvis.state` (structured object: current_session_start + sessions array of {start, end}). - Local-calendar "today" boundary, full Russian pluralisation (час/часа/часов, минута/минуты/минут, сессия/сессии/сессий). Tests: 139 rust (no regression), 81 python (60 → 81, +14 time_tracker +7 outlook). Release build green for jarvis-app and jarvis-cli. Pack count: 88 → 92 rust packs.
2026-05-16 14:34:29 +03:00
language_iso(target_label),
feat(commands): tier-1 — translate, math, theme toggle, project opener, sound panel Five more portable Lua command packs. Bumps the total from 16 to 21 packs. cargo test -p jarvis-core --lib commands::tests still 3/3. translate/ — translate.lua. Picks the target language from triggers like "переведи на английский" / "translate to russian"; falls back to English when only "переведи X" is heard. Sends to Groq with a strict "translation only" system prompt at temp 0.3. Drops the result into the clipboard, fires a notify, and speaks via PowerShell SAPI in the matching ISO voice (ru-RU / uk-UA / en-US / de-DE etc.) so a German translation actually sounds German. math/ — math.lua. Strips the trigger ("посчитай" / "calculate" / "сколько будет" / "what is" / ...), sends the remainder to Groq with temp=0.0 and max_tokens=64, asking ONLY for the numeric result. If the model replies "нет" (the system-prompt sentinel for non-math), plays not_found instead of speaking nonsense. Otherwise speaks "Получилось X" via SAPI. theme/ — set.lua dispatched by command_id (theme_dark / theme_light). Flips AppsUseLightTheme + SystemUsesLightTheme under HKCU\...\Themes\Personalize via Set-ItemProperty. No reboot needed, Windows shell re-themes immediately. projects/ — open.lua + list.lua. Reads/creates %USERPROFILE%\Documents\jarvis-projects.json (a flat [{"name": ..., "path": ...}] list). open.lua strips the trigger, exact-matches then substring-matches the project name, opens the path in VS Code if `code.cmd` is on PATH, otherwise in Explorer. First call creates a sample config with jarvis-rust / jarvis-python / dietpi entries pointing under USERPROFILE so it works on any machine. list.lua just notifies the configured project names. sound_panel/ — open.lua. Two-liner: rundll32 mmsys.cpl,,1 (Recording tab). Useful both as a standalone "открой настройки звука" and as the place to fix the mic-disabled state that prevents jarvis-app from starting. Portability: USERPROFILE / SystemDrive / PATH lookup throughout.
2026-05-15 12:06:30 +03:00
sapi_text
)
jarvis.system.exec(string.format('powershell -NoProfile -ExecutionPolicy Bypass -Command "%s"', ps:gsub('"', '\\"')))
jarvis.audio.play_ok()
return { chain = false }