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
|
|
@ -1,5 +1,8 @@
|
|||
mod events;
|
||||
mod server;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub use events::{IpcAction, IpcEvent};
|
||||
pub use server::{init, send, set_action_handler, start_server, has_clients, IPC_ADDR, IPC_PORT};
|
||||
203
crates/jarvis-core/src/ipc/tests.rs
Normal file
203
crates/jarvis-core/src/ipc/tests.rs
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
//! IPC event/action serialization tests.
|
||||
//!
|
||||
//! The frontend (Svelte) is wired to specific JSON shapes — adding/renaming
|
||||
//! a variant without thinking can silently break the websocket protocol.
|
||||
//! These tests pin the wire format.
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::super::events::{IpcEvent, IpcAction};
|
||||
// Note: in the crate layout `ipc/mod.rs` is at `ipc.rs` (single-file
|
||||
// module) and `events` is a sibling submodule, so `super::super::events`
|
||||
// works from inside this nested `mod tests` block.
|
||||
|
||||
fn ser(e: &IpcEvent) -> String {
|
||||
serde_json::to_string(e).unwrap()
|
||||
}
|
||||
|
||||
fn de_action(s: &str) -> IpcAction {
|
||||
serde_json::from_str(s).unwrap()
|
||||
}
|
||||
|
||||
// ── IpcEvent ─────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn event_wake_word_detected_uses_snake_case_tag() {
|
||||
let s = ser(&IpcEvent::WakeWordDetected);
|
||||
assert!(s.contains(r#""event":"wake_word_detected""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_listening_serializes() {
|
||||
let s = ser(&IpcEvent::Listening);
|
||||
assert!(s.contains(r#""event":"listening""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_speech_recognized_carries_text() {
|
||||
let s = ser(&IpcEvent::SpeechRecognized { text: "привет".into() });
|
||||
assert!(s.contains(r#""event":"speech_recognized""#));
|
||||
assert!(s.contains(r#""text":"привет""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_llm_reply_carries_text() {
|
||||
let s = ser(&IpcEvent::LlmReply { text: "hello".into() });
|
||||
assert!(s.contains(r#""event":"llm_reply""#));
|
||||
assert!(s.contains(r#""text":"hello""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_command_executed_carries_id_and_success() {
|
||||
let s = ser(&IpcEvent::CommandExecuted {
|
||||
id: "volume.set".into(),
|
||||
success: true,
|
||||
});
|
||||
assert!(s.contains(r#""event":"command_executed""#));
|
||||
assert!(s.contains(r#""id":"volume.set""#));
|
||||
assert!(s.contains(r#""success":true"#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_idle_minimal_payload() {
|
||||
let s = ser(&IpcEvent::Idle);
|
||||
assert!(s.contains(r#""event":"idle""#));
|
||||
// Should have no extra fields beyond the tag.
|
||||
let v: serde_json::Value = serde_json::from_str(&s).unwrap();
|
||||
assert_eq!(v.as_object().unwrap().len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_error_carries_message() {
|
||||
let s = ser(&IpcEvent::Error { message: "boom".into() });
|
||||
assert!(s.contains(r#""event":"error""#));
|
||||
assert!(s.contains(r#""message":"boom""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_health_snapshot_full_shape() {
|
||||
let s = ser(&IpcEvent::HealthSnapshot {
|
||||
tts_backend: "piper".into(),
|
||||
llm_backend: "groq".into(),
|
||||
llm_model: Some("llama-3.3-70b-versatile".into()),
|
||||
active_profile: "work".into(),
|
||||
memory_facts: 12,
|
||||
scheduled_tasks: 3,
|
||||
language: "ru".into(),
|
||||
version: Some("0.0.1".into()),
|
||||
});
|
||||
assert!(s.contains(r#""event":"health_snapshot""#));
|
||||
assert!(s.contains(r#""tts_backend":"piper""#));
|
||||
assert!(s.contains(r#""llm_backend":"groq""#));
|
||||
assert!(s.contains(r#""llm_model":"llama-3.3-70b-versatile""#));
|
||||
assert!(s.contains(r#""active_profile":"work""#));
|
||||
assert!(s.contains(r#""memory_facts":12"#));
|
||||
assert!(s.contains(r#""scheduled_tasks":3"#));
|
||||
assert!(s.contains(r#""language":"ru""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_health_snapshot_handles_null_model() {
|
||||
let s = ser(&IpcEvent::HealthSnapshot {
|
||||
tts_backend: "sapi".into(),
|
||||
llm_backend: "none".into(),
|
||||
llm_model: None,
|
||||
active_profile: "default".into(),
|
||||
memory_facts: 0,
|
||||
scheduled_tasks: 0,
|
||||
language: "ru".into(),
|
||||
version: None,
|
||||
});
|
||||
assert!(s.contains(r#""llm_model":null"#));
|
||||
assert!(s.contains(r#""version":null"#));
|
||||
}
|
||||
|
||||
// ── IpcAction ────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn action_stop_parses() {
|
||||
let a = de_action(r#"{"action":"stop"}"#);
|
||||
assert!(matches!(a, IpcAction::Stop));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn action_ping_parses() {
|
||||
let a = de_action(r#"{"action":"ping"}"#);
|
||||
assert!(matches!(a, IpcAction::Ping));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn action_text_command_parses_payload() {
|
||||
let a = de_action(r#"{"action":"text_command","text":"какая погода"}"#);
|
||||
match a {
|
||||
IpcAction::TextCommand { text } => assert_eq!(text, "какая погода"),
|
||||
_ => panic!("wrong variant"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn action_set_muted_parses_bool() {
|
||||
let a = de_action(r#"{"action":"set_muted","muted":true}"#);
|
||||
match a {
|
||||
IpcAction::SetMuted { muted } => assert!(muted),
|
||||
_ => panic!("wrong variant"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn action_switch_llm_parses_backend_name() {
|
||||
let a = de_action(r#"{"action":"switch_llm","backend":"ollama"}"#);
|
||||
match a {
|
||||
IpcAction::SwitchLlm { backend } => assert_eq!(backend, "ollama"),
|
||||
_ => panic!("wrong variant"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn action_reload_llm_parses() {
|
||||
let a = de_action(r#"{"action":"reload_llm"}"#);
|
||||
assert!(matches!(a, IpcAction::ReloadLlm));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn action_query_health_parses() {
|
||||
let a = de_action(r#"{"action":"query_health"}"#);
|
||||
assert!(matches!(a, IpcAction::QueryHealth));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn action_unknown_variant_fails() {
|
||||
let r = serde_json::from_str::<IpcAction>(r#"{"action":"do_a_barrel_roll"}"#);
|
||||
assert!(r.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn action_missing_required_field_fails() {
|
||||
// switch_llm requires "backend" payload
|
||||
let r = serde_json::from_str::<IpcAction>(r#"{"action":"switch_llm"}"#);
|
||||
assert!(r.is_err());
|
||||
}
|
||||
|
||||
// ── Cross-field stability ────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn event_tag_field_is_always_event() {
|
||||
// Documented contract: every event has an "event" key with snake-case tag.
|
||||
for variant in [
|
||||
IpcEvent::WakeWordDetected,
|
||||
IpcEvent::Listening,
|
||||
IpcEvent::Idle,
|
||||
IpcEvent::Started,
|
||||
IpcEvent::Stopping,
|
||||
IpcEvent::Pong,
|
||||
IpcEvent::RevealWindow,
|
||||
] {
|
||||
let s = ser(&variant);
|
||||
let v: serde_json::Value = serde_json::from_str(&s).unwrap();
|
||||
assert!(v.get("event").is_some(), "missing 'event' tag in: {}", s);
|
||||
assert!(v["event"].as_str().unwrap().chars()
|
||||
.all(|c| c.is_ascii_lowercase() || c == '_'),
|
||||
"non-snake-case tag in: {}", s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -122,17 +122,97 @@ pub fn log_effective_config() {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// Use a unique prefix so concurrent tests don't collide with real env vars.
|
||||
// Rust test runner uses threads inside a single process; serialize env mutations
|
||||
// by giving each test its own var name.
|
||||
fn set(name: &str, value: &str) {
|
||||
// SAFETY: tests are intentionally racy; each test uses unique names.
|
||||
unsafe { std::env::set_var(name, value); }
|
||||
}
|
||||
|
||||
fn unset(name: &str) {
|
||||
unsafe { std::env::remove_var(name); }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_bool_defaults() {
|
||||
assert!(!get_bool("JARVIS_NON_EXISTENT_XYZ", false));
|
||||
assert!(get_bool("JARVIS_NON_EXISTENT_XYZ", true));
|
||||
assert!(!get_bool("JARVIS_TEST_BOOL_DEFAULT_F", false));
|
||||
assert!(get_bool("JARVIS_TEST_BOOL_DEFAULT_T", true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_parse_typed_default() {
|
||||
let n: u32 = get_parse("JARVIS_NON_EXISTENT_XYZ", 42);
|
||||
let n: u32 = get_parse("JARVIS_TEST_PARSE_U32_DEF", 42);
|
||||
assert_eq!(n, 42);
|
||||
let f: f32 = get_parse("JARVIS_NON_EXISTENT_XYZ", 0.5);
|
||||
let f: f32 = get_parse("JARVIS_TEST_PARSE_F32_DEF", 0.5);
|
||||
assert!((f - 0.5).abs() < 0.001);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_bool_recognises_truthy_values() {
|
||||
for v in &["1", "true", "yes", "on", "TRUE", "Yes", "ON"] {
|
||||
set("JARVIS_TEST_BOOL_TRUTHY", v);
|
||||
assert!(get_bool("JARVIS_TEST_BOOL_TRUTHY", false), "expected true for '{}'", v);
|
||||
}
|
||||
unset("JARVIS_TEST_BOOL_TRUTHY");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_bool_recognises_falsy_values() {
|
||||
for v in &["0", "false", "no", "off", "anything else"] {
|
||||
set("JARVIS_TEST_BOOL_FALSY", v);
|
||||
assert!(!get_bool("JARVIS_TEST_BOOL_FALSY", true), "expected false for '{}'", v);
|
||||
}
|
||||
unset("JARVIS_TEST_BOOL_FALSY");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_strips_whitespace_and_treats_empty_as_unset() {
|
||||
set("JARVIS_TEST_GET_WHITESPACE", " ");
|
||||
assert_eq!(get("JARVIS_TEST_GET_WHITESPACE"), None);
|
||||
set("JARVIS_TEST_GET_WHITESPACE", " hello ");
|
||||
assert_eq!(get("JARVIS_TEST_GET_WHITESPACE"), Some("hello".into()));
|
||||
unset("JARVIS_TEST_GET_WHITESPACE");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn llm_router_threshold_falls_back_to_default() {
|
||||
unset(ENV_LLM_ROUTER_THRESHOLD);
|
||||
let t = llm_router_threshold();
|
||||
assert!((t - 0.55).abs() < 0.001, "default should be 0.55");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn llm_router_threshold_parses_custom_value() {
|
||||
set(ENV_LLM_ROUTER_THRESHOLD, "0.75");
|
||||
assert!((llm_router_threshold() - 0.75).abs() < 0.001);
|
||||
unset(ENV_LLM_ROUTER_THRESHOLD);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn llm_router_threshold_falls_back_on_garbage() {
|
||||
set(ENV_LLM_ROUTER_THRESHOLD, "not_a_number");
|
||||
let t = llm_router_threshold();
|
||||
assert!((t - 0.55).abs() < 0.001, "garbage should fall back to default");
|
||||
unset(ENV_LLM_ROUTER_THRESHOLD);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn llm_tts_enabled_default_is_true() {
|
||||
unset(ENV_LLM_TTS);
|
||||
assert!(llm_tts_enabled());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn llm_tts_enabled_false_when_explicitly_set() {
|
||||
set(ENV_LLM_TTS, "false");
|
||||
assert!(!llm_tts_enabled());
|
||||
unset(ENV_LLM_TTS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn llm_router_enabled_default_is_true() {
|
||||
unset(ENV_LLM_ROUTER);
|
||||
assert!(llm_router_enabled());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -535,4 +535,88 @@ mod tests {
|
|||
assert!(find_by_text_in(&tasks, "", 5).is_empty());
|
||||
assert!(find_by_text_in(&tasks, " ", 5).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_in_hours_yields_once() {
|
||||
let s = Schedule::parse("in 2 hours").unwrap();
|
||||
match s {
|
||||
Schedule::Once { at } => assert!(at > 0),
|
||||
_ => panic!("expected Once"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_at_today_or_tomorrow() {
|
||||
let s = Schedule::parse("at 23:59").unwrap();
|
||||
assert!(matches!(s, Schedule::Once { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_at_rejects_bad_time() {
|
||||
assert!(Schedule::parse("at 25:00").is_err());
|
||||
assert!(Schedule::parse("at 12:99").is_err());
|
||||
assert!(Schedule::parse("at notatime").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_daily_rejects_bad_hour() {
|
||||
assert!(Schedule::parse("daily 24:00").is_err());
|
||||
assert!(Schedule::parse("daily 12:60").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_every_seconds() {
|
||||
let s = Schedule::parse("every 30 seconds").unwrap();
|
||||
assert_eq!(s, Schedule::Interval { seconds: 30 });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_unrecognised_spec_errors() {
|
||||
assert!(Schedule::parse("nonsense").is_err());
|
||||
assert!(Schedule::parse("daily").is_err());
|
||||
assert!(Schedule::parse("every").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn task_serde_round_trip() {
|
||||
let t = ScheduledTask {
|
||||
id: "abc".into(),
|
||||
name: "Test".into(),
|
||||
schedule: Schedule::Daily { hour: 9, minute: 0 },
|
||||
action: Action::Speak { text: "wake up".into() },
|
||||
last_fired: Some(1000),
|
||||
enabled: true,
|
||||
created_at: 500,
|
||||
};
|
||||
let json = serde_json::to_string(&t).unwrap();
|
||||
let back: ScheduledTask = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(back.id, "abc");
|
||||
assert_eq!(back.last_fired, Some(1000));
|
||||
match back.action {
|
||||
Action::Speak { text } => assert_eq!(text, "wake up"),
|
||||
_ => panic!("wrong action variant"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schedule_kind_tag_in_json() {
|
||||
// Verify we use a stable JSON shape with `kind` discriminator.
|
||||
let s = Schedule::Daily { hour: 8, minute: 30 };
|
||||
let json = serde_json::to_string(&s).unwrap();
|
||||
assert!(json.contains(r#""kind":"daily""#));
|
||||
assert!(json.contains(r#""hour":8"#));
|
||||
assert!(json.contains(r#""minute":30"#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn action_serde_lua_variant() {
|
||||
let a = Action::Lua { script_path: "C:/path/foo.lua".into() };
|
||||
let json = serde_json::to_string(&a).unwrap();
|
||||
// serde with default `rename_all = "snake_case"` on enum gives "lua"/"speak" tags
|
||||
let back: Action = serde_json::from_str(&json).unwrap();
|
||||
match back {
|
||||
Action::Lua { script_path } => assert_eq!(script_path, "C:/path/foo.lua"),
|
||||
_ => panic!("wrong action variant"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
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