Add Discord-native hybrid front-end for Jarvis (bot + bridge)
Some checks failed
Release / semantic-release (push) Successful in 59s
tests / Unit tests (Linux, Python 3.11) (push) Successful in 13m45s
Release / build-linux (push) Failing after 7m47s
Release / build-windows (push) Has been cancelled
Release / build-macos (arm64, macos-latest) (push) Has been cancelled
Release / build-macos (x64, macos-15-intel) (push) Has been cancelled
Release / release-main (push) Has been cancelled
Release / release-develop (push) Has been cancelled

Transform isair/jarvis into a Discord-controlled voice assistant running on
the Ubuntu VNC desktop, keeping the mature ~39k-line Python brain intact.

- bot/ (Node + bun, discord.js): /자비스 slash commands (ephemeral),
  voice channel join + voice receive/playback, pluggable VNC screen broadcast
  (selfbot live / noVNC / screenshot)
- bridge/ (Python, Flask): wraps jarvis STT + run_reply_engine + Piper TTS
  behind a thin localhost HTTP API
- .env.example, scripts/ (start_bridge/start_bot/dev), README rewrite,
  docs/language-comparison.md and docs/vnc-xfce-setup.md

Language decision: hybrid (Python brain + Node/bun Discord layer) because
Discord blocks bot video; native screen broadcast only works via a Node
selfbot library.
This commit is contained in:
javis-bot
2026-06-09 14:51:05 +09:00
parent a5bf8d1826
commit c4abf63f38
308 changed files with 94135 additions and 1 deletions

View File

@@ -0,0 +1,88 @@
"""
Tests for wake word detection and query extraction.
"""
import pytest
from jarvis.listening.wake_detection import (
is_wake_word_detected,
extract_query_after_wake,
is_stop_command,
)
@pytest.mark.unit
class TestWakeWordDetection:
"""Tests for is_wake_word_detected."""
def test_exact_match(self):
assert is_wake_word_detected("hey jarvis", "jarvis", []) is True
def test_alias_match(self):
assert is_wake_word_detected("hey computer", "jarvis", ["computer"]) is True
def test_no_match(self):
assert is_wake_word_detected("hello world", "jarvis", []) is False
def test_empty_text(self):
assert is_wake_word_detected("", "jarvis", []) is False
def test_fuzzy_match(self):
"""Fuzzy matching catches slight transcription errors."""
assert is_wake_word_detected("hey jarvas", "jarvis", [], fuzzy_ratio=0.78) is True
def test_fuzzy_below_threshold(self):
"""Completely different word doesn't fuzzy-match."""
assert is_wake_word_detected("hey banana", "jarvis", [], fuzzy_ratio=0.78) is False
@pytest.mark.unit
class TestExtractQueryAfterWake:
"""Tests for extract_query_after_wake."""
def test_extracts_query(self):
result = extract_query_after_wake("jarvis what time is it", "jarvis", [])
assert result == "what time is it"
def test_extracts_query_with_alias(self):
result = extract_query_after_wake("hey computer what time is it", "jarvis", ["hey computer"])
assert result == "what time is it"
def test_wake_word_only_returns_empty(self):
"""When only the wake word is said, return empty string (no hardcoded fallback)."""
result = extract_query_after_wake("jarvis", "jarvis", [])
assert result == ""
def test_wake_word_with_punctuation_only_returns_empty(self):
"""Wake word followed by just punctuation returns empty string."""
result = extract_query_after_wake("jarvis,", "jarvis", [])
assert result == ""
def test_empty_text(self):
result = extract_query_after_wake("", "jarvis", [])
assert result == ""
def test_strips_leading_punctuation(self):
result = extract_query_after_wake("jarvis, tell me a joke", "jarvis", [])
assert result == "tell me a joke"
@pytest.mark.unit
class TestStopCommand:
"""Tests for is_stop_command."""
def test_exact_stop_command(self):
assert is_stop_command("stop", ["stop", "quiet"]) is True
def test_stop_command_in_phrase(self):
assert is_stop_command("please stop talking", ["stop", "quiet"]) is True
def test_no_stop_command(self):
assert is_stop_command("what is the weather", ["stop", "quiet"]) is False
def test_empty_text(self):
assert is_stop_command("", ["stop", "quiet"]) is False
def test_fuzzy_stop_command(self):
"""Short input fuzzy-matches stop commands."""
assert is_stop_command("stob", ["stop", "quiet"], fuzzy_ratio=0.7) is True