feat(commands): tier-1 PC tools — window mgmt, clipboard, notes, process killer, web search

Five new portable Lua command packs. Bumps the total from 11 to 16 packs.
All sandbox=full, all dispatched via jarvis.system.exec or jarvis.fs / jarvis.system
APIs, no new Rust code, post_build.py --sync copies them under target/.
cargo test -p jarvis-core --lib commands::tests passes 3/3 against all 16.

window/ — 8 commands, single dispatch.lua keyed by jarvis.context.command_id:
  show_desktop / maximize_window / minimize_window / snap_left / snap_right
  / close_window / restore_all / task_view. _window_helper.ps1 P/Invokes
  user32!keybd_event for arbitrary combos like "win+d", "alt+f4",
  "win+shift+m". Uses one shared script per pack — much less duplication
  than the volume/ approach.

clipboard_read/ — read_clipboard. Pulls jarvis.system.clipboard.get(),
caps preview at 400 chars, then shells PowerShell System.Speech to actually
speak it aloud (auto-picks the first ru-RU voice if present). Also fires a
notify with a 120-char snippet.

notes/ — add_note + open_notes. add_note strips the trigger phrase from
the recognized voice, appends "[YYYY-MM-DD HH:MM] body\n" to
%USERPROFILE%\Documents\jarvis-notes.txt via jarvis.fs.append (creates
the file on first call). open_notes opens the file in the default editor
via jarvis.system.open. Trigger list covers RU/EN/UA variants of
"запиши" / "запомни" / "write down" / etc.

process_kill/ — kill_process. Trigger-strips "закрой программу" / "убей
процесс" / etc., then runs the remainder through an alias map (хром→
chrome, телега→telegram, спотифай→spotify, edge/edge/едж→msedge etc.,
20+ entries) before invoking taskkill /F /IM. Notifies success/not-found.

websearch/ — search_google / search_youtube / search_wiki / search_yandex.
Single dispatch.lua reads jarvis.context.command_id to pick the base URL,
URL-encodes the query (Lua %02X gsub, not relying on jarvis.http), opens
the resulting link via jarvis.system.open (system default browser).

Portability check: every helper resolves paths via $env:USERPROFILE /
jarvis.context.command_path / jarvis.system.env — no hardcoded C:\ refs.
This commit is contained in:
Bossiara13 2026-05-15 11:27:02 +03:00
parent 3d127f05c0
commit 16ef413962
12 changed files with 545 additions and 0 deletions

View file

@ -0,0 +1,71 @@
[[commands]]
id = "search_google"
type = "lua"
script = "dispatch.lua"
sandbox = "full"
timeout = 5000
[commands.phrases]
ru = [
"загугли",
"поиск в гугл",
"поищи в гугл",
"найди в гугл",
"ищи в гугл",
]
en = ["google", "search google", "google for"]
ua = ["загугли", "пошукай в гугл"]
[[commands]]
id = "search_youtube"
type = "lua"
script = "dispatch.lua"
sandbox = "full"
timeout = 5000
[commands.phrases]
ru = [
"найди на ютубе",
"поиск на ютубе",
"ищи на ютубе",
"ютуб поиск",
]
en = ["youtube search", "search youtube", "find on youtube"]
ua = ["знайди на ютубі", "пошук на ютубі"]
[[commands]]
id = "search_wiki"
type = "lua"
script = "dispatch.lua"
sandbox = "full"
timeout = 5000
[commands.phrases]
ru = [
"найди в википедии",
"поиск в википедии",
"википедия",
"вики поиск",
]
en = ["wikipedia search", "search wikipedia", "look up wikipedia"]
ua = ["знайди в вікіпедії", "пошук у вікіпедії"]
[[commands]]
id = "search_yandex"
type = "lua"
script = "dispatch.lua"
sandbox = "full"
timeout = 5000
[commands.phrases]
ru = [
"поищи в яндекс",
"найди в яндекс",
"яндекс поиск",
"пробей в яндекс",
]
en = ["yandex search", "search yandex"]
ua = ["знайди в яндекс"]

View file

@ -0,0 +1,61 @@
local lang = jarvis.context.language
local phrase = (jarvis.context.phrase or ""):lower()
local cmd_id = jarvis.context.command_id
local services = {
search_google = { base = "https://www.google.com/search?q=", label = "Google" },
search_youtube = { base = "https://www.youtube.com/results?search_query=", label = "YouTube" },
search_wiki = { base = "https://ru.wikipedia.org/wiki/Special:Search?search=", label = "Wikipedia" },
search_yandex = { base = "https://yandex.ru/search/?text=", label = "Yandex" },
}
local svc = services[cmd_id]
if not svc then
jarvis.log("error", "websearch: unknown command_id " .. tostring(cmd_id))
jarvis.audio.play_error()
return { chain = false }
end
local triggers = {
"загугли", "поиск в гугл", "поищи в гугл", "найди в гугл", "ищи в гугл",
"найди на ютубе", "поиск на ютубе", "ищи на ютубе", "ютуб поиск",
"найди в википедии", "поиск в википедии", "википедия", "вики поиск",
"поищи в яндекс", "найди в яндекс", "яндекс поиск", "пробей в яндекс",
"search google", "google for", "google",
"youtube search", "search youtube", "find on youtube",
"wikipedia search", "search wikipedia", "look up wikipedia",
"yandex search", "search yandex",
"загугли", "пошукай в гугл",
"знайди на ютубі", "пошук на ютубі",
"знайди в вікіпедії", "пошук у вікіпедії",
"знайди в яндекс",
}
local q = phrase
for _, t in ipairs(triggers) do
local s, e = string.find(q, t, 1, true)
if s == 1 then
q = q:sub(e + 1)
break
end
end
q = q:gsub("^%s+", ""):gsub("%s+$", "")
if q == "" then
jarvis.system.notify(svc.label, lang == "ru" and "Что искать?" or "What to search?")
jarvis.audio.play_error()
return { chain = false }
end
local function url_encode(s)
return (s:gsub("([^%w%-_%.~])", function(c)
return string.format("%%%02X", string.byte(c))
end))
end
local url = svc.base .. url_encode(q)
jarvis.log("info", "websearch " .. svc.label .. ": " .. q)
jarvis.system.open(url)
jarvis.system.notify(svc.label, q)
jarvis.audio.play_ok()
return { chain = false }