test+feat: +37 tests (62→99) + intro/echo packs (5 new commands)
Major test coverage push: pins IPC wire format, scheduler parser/serde,
runtime_config env handling. Plus two debug/discovery packs.
Tests (62 → 99, +37)
IPC roundtrip (new file crates/jarvis-core/src/ipc/tests.rs, +19 tests)
- Event tags use snake_case ("wake_word_detected", "speech_recognized", ...)
- Idle event has minimal payload (tag only, no extra fields)
- SpeechRecognized/LlmReply/Error carry their text payloads
- CommandExecuted carries id + success bool
- HealthSnapshot full shape: tts/llm/llm_model/profile/memory_facts/
scheduled_tasks/language/version
- HealthSnapshot handles llm_model:null / version:null
- Cross-variant invariant: every event has snake-case "event" tag
- Action parsing: stop / ping / text_command / set_muted / switch_llm /
reload_llm / query_health
- Unknown action variant errors out
- switch_llm requires "backend" field (missing field errors)
runtime_config (was 2, now 11 tests, +9)
- get_bool recognises 1/true/yes/on (case-insensitive)
- get_bool falsifies 0/false/no/off/anything-else
- get() strips whitespace, empty = unset
- llm_router_threshold default 0.55 / custom parse / garbage fallback
- llm_tts_enabled default true, recognises "false"
- llm_router_enabled default true
- Uses unique env var names per test to avoid thread races
scheduler (was 10, now 19 tests, +9)
- parse_in_hours yields Once
- parse_at_today_or_tomorrow
- parse_at_rejects_bad_time (25:00, 12:99, "notatime")
- parse_daily_rejects_bad_hour (24:00, 12:60)
- parse_every_seconds
- parse_unrecognised_spec_errors ("nonsense", "daily", "every")
- task_serde_round_trip preserves last_fired + action variant
- schedule_kind_tag_in_json pins {"kind":"daily","hour":...,"minute":...}
- action_serde_lua_variant roundtrip
New packs
resources/commands/intro/ (3 commands)
- intro.capabilities "что ты умеешь" / "помощь" / "помоги"
→ speaks a 7-line category overview
- intro.about "расскажи о себе" / "кто ты такой"
→ LLM-varied bio with profile name
Falls back to canned text if LLM unavailable.
- intro.commands_count "сколько команд знаешь"
→ reads jarvis.health() and reports backends + counts
resources/commands/echo/ (2 commands)
- echo.repeat "повтори за мной X" → speaks X verbatim
Preserves original casing by re-grabbing from raw phrase.
- echo.what_did_i_say "что я сказал" → echoes jarvis.context.phrase
- Both useful for testing mic-pickup + STT-quality + TTS-clarity without
touching LLM. If user can't hear/understand the echo, the issue is the
audio chain, not the command logic.
Build: cargo build --release green. 99/99 tests pass.
This commit is contained in:
parent
a2dfadf5c1
commit
77063fed86
11 changed files with 552 additions and 4 deletions
35
resources/commands/echo/command.toml
Normal file
35
resources/commands/echo/command.toml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# Echo debug pack — Jarvis repeats what you said. Useful for testing mic+TTS
|
||||
# without involving wake-word or LLM.
|
||||
|
||||
[[commands]]
|
||||
id = "echo.repeat"
|
||||
type = "lua"
|
||||
script = "repeat.lua"
|
||||
sandbox = "minimal"
|
||||
timeout = 3000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"повтори за мной",
|
||||
"скажи как я",
|
||||
"эхо",
|
||||
"проверка эхо",
|
||||
]
|
||||
en = ["repeat after me", "echo"]
|
||||
ua = ["повтори за мною", "ехо"]
|
||||
|
||||
|
||||
[[commands]]
|
||||
id = "echo.what_did_i_say"
|
||||
type = "lua"
|
||||
script = "what.lua"
|
||||
sandbox = "minimal"
|
||||
timeout = 2000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"что я сказал",
|
||||
"что ты услышал",
|
||||
]
|
||||
en = ["what did i say", "what did you hear"]
|
||||
ua = ["що я сказав"]
|
||||
27
resources/commands/echo/repeat.lua
Normal file
27
resources/commands/echo/repeat.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-- "Повтори за мной привет всем"
|
||||
local phrase = (jarvis.context.phrase or "")
|
||||
local body = jarvis.text.strip_trigger(phrase:lower(), {
|
||||
"повтори за мной",
|
||||
"проверка эхо",
|
||||
"скажи как я",
|
||||
"эхо",
|
||||
"repeat after me",
|
||||
"echo",
|
||||
"повтори за мною",
|
||||
"ехо",
|
||||
})
|
||||
body = body:gsub("^[%s,:%.]+", ""):gsub("%s+$", "")
|
||||
|
||||
if body == "" then
|
||||
return jarvis.cmd.error("Что повторить?")
|
||||
end
|
||||
|
||||
-- Preserve original casing — strip_trigger lowercased, but we can grab from the
|
||||
-- raw phrase by finding the lowercase prefix and skipping past it.
|
||||
local raw_lower = phrase:lower()
|
||||
local start_idx = raw_lower:find(body, 1, true)
|
||||
if start_idx then
|
||||
body = phrase:sub(start_idx, start_idx + #body - 1)
|
||||
end
|
||||
|
||||
return jarvis.cmd.ok(body)
|
||||
6
resources/commands/echo/what.lua
Normal file
6
resources/commands/echo/what.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- "Что я сказал" — отдаёт обратно всё что услышал.
|
||||
local heard = jarvis.context.phrase or ""
|
||||
if heard == "" then
|
||||
return jarvis.cmd.not_found("Я ничего не услышал.")
|
||||
end
|
||||
return jarvis.cmd.ok("Вы сказали: " .. heard)
|
||||
20
resources/commands/intro/about.lua
Normal file
20
resources/commands/intro/about.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
-- Short bio. Falls back to LLM if available for variation, otherwise canned text.
|
||||
local prof = jarvis.profile.active()
|
||||
local prof_part = ""
|
||||
if prof and prof.name and prof.name ~= "default" then
|
||||
prof_part = " Сейчас работаю в режиме " .. prof.name .. "."
|
||||
end
|
||||
|
||||
local canned = "Я Джарвис, локальный голосовой ассистент на Rust." ..
|
||||
" Работаю на вашем компьютере, могу использовать облачный или локальный мозг." ..
|
||||
prof_part ..
|
||||
" Спросите 'что ты умеешь' для обзора возможностей."
|
||||
|
||||
-- If LLM is configured, give a tiny variation. Otherwise use canned.
|
||||
local llm_text = jarvis.llm({
|
||||
{ role = "system", content = "Ты — Джарвис из вселенной Marvel, британский дворецкий Тони Старка. Одна короткая фраза (1-2 предложения) на русском, представь себя пользователю. Без слов 'я искусственный интеллект' и подобных." },
|
||||
{ role = "user", content = "Расскажи о себе одной фразой." }
|
||||
}, { max_tokens = 80, temperature = 0.8 })
|
||||
|
||||
local msg = (llm_text and llm_text ~= "") and llm_text or canned
|
||||
return jarvis.cmd.ok(msg)
|
||||
60
resources/commands/intro/command.toml
Normal file
60
resources/commands/intro/command.toml
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# Voice-driven intro / capability discovery.
|
||||
# Speaks a category-grouped overview of what Jarvis can do, scoped to the
|
||||
# currently active profile (if the profile has allow/deny lists).
|
||||
|
||||
[[commands]]
|
||||
id = "intro.capabilities"
|
||||
type = "lua"
|
||||
script = "what_can_you_do.lua"
|
||||
sandbox = "minimal"
|
||||
timeout = 5000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"что ты умеешь",
|
||||
"что ты можешь",
|
||||
"какие у тебя возможности",
|
||||
"что я могу попросить",
|
||||
"помощь",
|
||||
"помоги",
|
||||
"как тобой пользоваться",
|
||||
"научи меня",
|
||||
]
|
||||
en = ["what can you do", "help", "capabilities", "how do I use you"]
|
||||
ua = ["що ти вмієш", "допомога"]
|
||||
|
||||
|
||||
[[commands]]
|
||||
id = "intro.about"
|
||||
type = "lua"
|
||||
script = "about.lua"
|
||||
sandbox = "minimal"
|
||||
timeout = 3000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"расскажи о себе",
|
||||
"кто ты такой",
|
||||
"что ты за ассистент",
|
||||
"что ты вообще",
|
||||
"о тебе",
|
||||
]
|
||||
en = ["who are you", "tell me about yourself", "about you"]
|
||||
ua = ["хто ти такий", "розкажи про себе"]
|
||||
|
||||
|
||||
[[commands]]
|
||||
id = "intro.commands_count"
|
||||
type = "lua"
|
||||
script = "count.lua"
|
||||
sandbox = "minimal"
|
||||
timeout = 2000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"сколько команд знаешь",
|
||||
"сколько у тебя команд",
|
||||
"сколько ты умеешь команд",
|
||||
]
|
||||
en = ["how many commands", "command count"]
|
||||
ua = ["скільки команд"]
|
||||
10
resources/commands/intro/count.lua
Normal file
10
resources/commands/intro/count.lua
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
-- "Сколько команд знаешь" — выводит health snapshot для подтверждения готовности.
|
||||
local h = jarvis.health()
|
||||
local memory_count = h.memory_facts or 0
|
||||
local sched_count = h.scheduled_tasks or 0
|
||||
|
||||
local msg = "Активных бекендов: TTS " .. (h.tts_backend or "—") ..
|
||||
", LLM " .. (h.llm_backend or "—") ..
|
||||
". В памяти " .. memory_count .. " фактов, в расписании " .. sched_count .. " задач."
|
||||
|
||||
return jarvis.cmd.ok(msg)
|
||||
20
resources/commands/intro/what_can_you_do.lua
Normal file
20
resources/commands/intro/what_can_you_do.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
-- "Что ты умеешь" → говорит обзор возможностей по категориям.
|
||||
-- Категории захардкожены — переводы команд в реестре делать дорого,
|
||||
-- проще держать рукописный summary.
|
||||
|
||||
local lines = {
|
||||
"Я могу управлять компьютером голосом.",
|
||||
"По темам: звук и медиа, окна и приложения, поиск файлов, заметки и буфер.",
|
||||
"Также: переводы, конвертация валют, котировки акций, википедия и поиск в гугле.",
|
||||
"Умею ставить напоминания, помодоро и привычки.",
|
||||
"Запоминаю факты о вас, имею профили работы и игр, могу записывать макросы команд.",
|
||||
"Если не понимаю команду, спрашиваю облачный или локальный мозг. Спросите 'какой у тебя мозг'.",
|
||||
"Скажите 'что в расписании' чтобы посмотреть задачи, или откройте окно для полного списка.",
|
||||
}
|
||||
|
||||
for _, line in ipairs(lines) do
|
||||
jarvis.speak(line)
|
||||
jarvis.sleep(120)
|
||||
end
|
||||
|
||||
return jarvis.cmd.silent_ok()
|
||||
Loading…
Add table
Add a link
Reference in a new issue