Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(commands): command registry — one machine-readable catalog of app commands

Ruben Lütke9acad0bd294b
diff --git a/jarvis/commands/__init__.py b/jarvis/commands/__init__.py
new file mode 100644
index 0000000000..f322e29e08
--- /dev/null
+++ b/jarvis/commands/__init__.py
@@ -0,0 +1,9 @@
+"""Command Registry package — one machine-readable catalog of app commands."""
+from jarvis.commands.registry import (
+ AppCommand,
+ get_command,
+ get_registry,
+ registry_as_dicts,
+)
+
+__all__ = ["AppCommand", "get_command", "get_registry", "registry_as_dicts"]
diff --git a/jarvis/commands/registry.py b/jarvis/commands/registry.py
new file mode 100644
index 0000000000..c303e248b4
--- /dev/null
+++ b/jarvis/commands/registry.py
@@ -0,0 +1,509 @@
+"""Command Registry — ONE machine-readable catalog of user-facing app commands.
+
+The registry is the single source of truth that lets every surface agree on
+what a "command" is (the AP-4 anti-drift class):
+
+- the brain's ``app-command`` router tool (pipeline voice/chat) exposes the
+ catalog to the LLM as an enum-constrained schema,
+- ``GET /api/commands`` serves it to the desktop UI (and, via the dynamic
+ OpenAPI layer, to the ``jarvis`` CLI),
+- ``scripts/ci/gen_commands_reference.py`` renders it into
+ ``docs/commands-reference.md`` (drift-gated),
+- Phase B wires the same catalog into the realtime engines' tool calling.
+
+Every command maps to exactly ONE already-mounted, already-validated REST
+endpoint — the registry never grows its own execution logic, so command
+behavior can never drift from what the UI button for the same action does.
+Parity tests (tests/unit/commands/) assert every entry's endpoint exists in
+the live OpenAPI schema and every ``ui_section`` is a real sidebar section.
+
+Latency & footprint: the catalog is plain in-process data built lazily on
+first access (AP-26 — nothing here touches the boot critical path) and
+measures a few KB.
+
+Language note: ``voice_aliases`` values are speech-recognition INPUT
+vocabulary (CLAUDE.md §1 closed list #3) and therefore may be non-English;
+every other string in this module is English.
+"""
+from __future__ import annotations
+
+from dataclasses import dataclass, field
+from functools import lru_cache
+from typing import Any
+
+# Kept static for zero-import-cost; parity-tested against
+# jarvis.brain.manager.SUPPORTED_REPLY_LANGUAGES (the authoritative tuple).
+REPLY_LANGUAGES: tuple[str, ...] = ("auto", "de", "en", "es")
+
+VOICE_MODES: tuple[str, ...] = ("pipeline", "realtime")
+
+
+@dataclass(frozen=True)
+class AppCommand:
+ """One user-facing app command, bound to exactly one REST endpoint."""
+
+ id: str # stable kebab-case identifier
+ title: str # short human-readable title (EN)
+ description: str # one-liner for the LLM schema + docs (EN)
+ method: str # HTTP method of the backing endpoint
+ path: str # endpoint path, may contain {placeholders}
+ params: dict[str, Any] = field(default_factory=dict) # JSON schema (object)
+ path_params: tuple[str, ...] = () # args substituted into the path
+ dangerous: bool = False # True → requires explicit confirmation
+ ui_section: str = "settings" # sidebar section hosting the same action
+ voice_aliases: dict[str, tuple[str, ...]] = field(default_factory=dict)
+
+ def as_dict(self) -> dict[str, Any]:
+ return {
+ "id": self.id,
+ "title": self.title,
+ "description": self.description,
+ "method": self.method,
+ "path": self.path,
+ "params": self.params,
+ "path_params": list(self.path_params),
+ "dangerous": self.dangerous,
+ "ui_section": self.ui_section,
+ "voice_aliases": {k: list(v) for k, v in self.voice_aliases.items()},
+ }
+
+
+def _provider_ids(tier: str, *, brain_switchable_only: bool = False) -> list[str]:
+ """Provider ids for ``tier`` from the static catalog; [] when unavailable.
+
+ Lazy import: the provider catalog is pure data, but this module must stay
+ importable (docs generation, tests) without pulling the UI layer eagerly.
+ """
+ try:
+ from jarvis.ui.web.provider_spec import PROVIDERS
+ except Exception: # pragma: no cover - defensive: registry must not crash
+ return []
+ ids = [
+ p.id
+ for p in PROVIDERS
+ if p.tier == tier
+ and (not brain_switchable_only or getattr(p, "brain_switchable", True))
+ ]
+ return sorted(ids)
+
+
+def _all_provider_ids() -> list[str]:
+ try:
+ from jarvis.ui.web.provider_spec import PROVIDERS
+ except Exception: # pragma: no cover - defensive
+ return []
+ return sorted(p.id for p in PROVIDERS)
+
+
+def _str_param(description: str, *, enum: list[str] | None = None,
+ min_length: int | None = None, max_length: int | None = None,
+ ) -> dict[str, Any]:
+ schema: dict[str, Any] = {"type": "string", "description": description}
+ if enum:
+ schema["enum"] = enum
+ if min_length is not None:
+ schema["minLength"] = min_length
+ if max_length is not None:
+ schema["maxLength"] = max_length
+ return schema
+
+
+def _provider_switch_params(tier: str, *, brain_switchable_only: bool = False,
+ ) -> dict[str, Any]:
+ enum = _provider_ids(tier, brain_switchable_only=brain_switchable_only)
+ return {
+ "type": "object",
+ "properties": {
+ "provider": _str_param(
+ f"Target {tier} provider id.", enum=enum or None, min_length=1
+ ),
+ "persist": {
+ "type": "boolean",
+ "default": True,
+ "description": "Persist the choice to jarvis.toml (survives restart).",
+ },
+ },
+ "required": ["provider"],
+ }
+
+
+def _build_registry() -> tuple[AppCommand, ...]:
+ """Assemble the curated v1 command set (high-value commands first —
+ the long tail stays reachable through the dynamic CLI ``api`` layer)."""
+ return (
+ # ------------------------------------------------------ providers
+ AppCommand(
+ id="brain-switch",
+ title="Switch brain provider",
+ description=(
+ "Switch the ACTIVE main brain (LLM) provider, e.g. from openai "
+ "to claude-api. Reversible; validated against the provider "
+ "catalog and stored credentials."
+ ),
+ method="POST",
+ path="/api/brain/switch",
+ params=_provider_switch_params("brain", brain_switchable_only=True),
+ ui_section="apikeys",
+ voice_aliases={
+ "de": ("wechsle den brain-provider zu claude",), # i18n-allow: STT input vocabulary
+ "en": ("switch the brain provider to claude",),
+ "es": ("cambia el proveedor del cerebro a claude",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="tts-switch",
+ title="Switch voice (TTS) provider",
+ description="Switch the active text-to-speech provider (live, no restart).",
+ method="POST",
+ path="/api/tts/switch",
+ params=_provider_switch_params("tts"),
+ ui_section="apikeys",
+ voice_aliases={
+ "de": ("wechsle die stimme zu elevenlabs",), # i18n-allow: STT input vocabulary
+ "en": ("switch the voice to elevenlabs",),
+ "es": ("cambia la voz a elevenlabs",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="stt-switch",
+ title="Switch speech-recognition (STT) provider",
+ description=(
+ "Switch the speech-to-text provider. Takes effect on the next "
+ "voice-pipeline start (restart required)."
+ ),
+ method="POST",
+ path="/api/stt/switch",
+ params=_provider_switch_params("stt"),
+ ui_section="apikeys",
+ voice_aliases={
+ "de": ("wechsle die spracherkennung zu deepgram",), # i18n-allow: STT input vocabulary
+ "en": ("switch speech recognition to deepgram",),
+ "es": ("cambia el reconocimiento de voz a deepgram",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="realtime-switch",
+ title="Switch realtime voice provider",
+ description=(
+ "Switch which realtime voice engine (speech-to-speech) is "
+ "active, e.g. openai-realtime or gemini-live."
+ ),
+ method="POST",
+ path="/api/realtime/switch",
+ params=_provider_switch_params("realtime"),
+ ui_section="apikeys",
+ voice_aliases={
+ "de": ("wechsle das realtime-modell zu gemini",), # i18n-allow: STT input vocabulary
+ "en": ("switch the realtime model to gemini",),
+ "es": ("cambia el modelo en tiempo real a gemini",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="computer-use-switch",
+ title="Switch Computer-Use provider",
+ description=(
+ "Switch the dedicated Computer-Use planner provider (screen "
+ "control), decoupled from the main brain."
+ ),
+ method="POST",
+ path="/api/computer-use/switch",
+ params=_provider_switch_params("brain"),
+ ui_section="apikeys",
+ voice_aliases={
+ "de": ("wechsle den computer-use-provider zu gemini",), # i18n-allow: STT input vocabulary
+ "en": ("switch the computer use provider to gemini",),
+ "es": ("cambia el proveedor de computer use a gemini",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="jarvis-agent-switch",
+ title="Switch Jarvis-Agent (worker) provider",
+ description=(
+ "Switch the Jarvis-Agent / worker provider used for missions "
+ "(e.g. codex to openai). Restart required."
+ ),
+ method="POST",
+ path="/api/jarvis-agent/switch",
+ params=_provider_switch_params("brain"),
+ ui_section="agents",
+ voice_aliases={
+ "de": ("wechsle den agent-provider zu openai",), # i18n-allow: STT input vocabulary
+ "en": ("switch the agent provider to openai",),
+ "es": ("cambia el proveedor del agente a openai",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="providers-list",
+ title="List providers",
+ description="List all configured providers and which ones are active.",
+ method="GET",
+ path="/api/providers",
+ ui_section="apikeys",
+ voice_aliases={
+ "de": ("welche provider sind konfiguriert",), # i18n-allow: STT input vocabulary
+ "en": ("which providers are configured",),
+ "es": ("qué proveedores están configurados",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="provider-test",
+ title="Test a provider",
+ description="Test connectivity and authentication for one provider.",
+ method="POST",
+ path="/api/providers/{provider_id}/test",
+ params={
+ "type": "object",
+ "properties": {
+ "provider_id": _str_param(
+ "Provider id to test.", enum=_all_provider_ids() or None,
+ min_length=1,
+ ),
+ },
+ "required": ["provider_id"],
+ },
+ path_params=("provider_id",),
+ ui_section="apikeys",
+ voice_aliases={
+ "de": ("teste den openai-provider",), # i18n-allow: STT input vocabulary
+ "en": ("test the openai provider",),
+ "es": ("prueba el proveedor de openai",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ # ------------------------------------------------- voice & language
+ AppCommand(
+ id="reply-language-set",
+ title="Set reply language",
+ description=(
+ "Pin the language Jarvis answers in (auto follows the spoken "
+ "language)."
+ ),
+ method="PUT",
+ path="/api/settings/reply-language",
+ params={
+ "type": "object",
+ "properties": {
+ "language": _str_param(
+ "Reply language.", enum=list(REPLY_LANGUAGES)
+ ),
+ "persist": {
+ "type": "boolean", "default": True,
+ "description": "Persist as boot default.",
+ },
+ },
+ "required": ["language"],
+ },
+ ui_section="languages",
+ voice_aliases={
+ "de": ("antworte ab jetzt auf englisch",), # i18n-allow: STT input vocabulary
+ "en": ("answer in german from now on",),
+ "es": ("responde en inglés a partir de ahora",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="voice-mode-set",
+ title="Set voice mode (pipeline / realtime)",
+ description=(
+ "Choose the voice engine: the classic STT-brain-TTS pipeline "
+ "or a realtime speech-to-speech model."
+ ),
+ method="PUT",
+ path="/api/settings/voice-mode",
+ params={
+ "type": "object",
+ "properties": {
+ "mode": _str_param("Voice mode.", enum=list(VOICE_MODES)),
+ "persist": {
+ "type": "boolean", "default": True,
+ "description": "Persist as boot default.",
+ },
+ },
+ "required": ["mode"],
+ },
+ ui_section="settings",
+ voice_aliases={
+ "de": ("schalte auf den realtime-modus um",), # i18n-allow: STT input vocabulary
+ "en": ("switch to realtime mode",),
+ "es": ("cambia al modo en tiempo real",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="wake-word-get",
+ title="Show wake word",
+ description="Show the current wake word and wake-engine settings.",
+ method="GET",
+ path="/api/settings/wake-word",
+ ui_section="settings",
+ voice_aliases={
+ "de": ("wie lautet mein wake word",), # i18n-allow: STT input vocabulary
+ "en": ("what is my wake word",),
+ "es": ("cuál es mi palabra de activación",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="wake-word-set",
+ title="Change wake word",
+ description="Set the phrase that wakes Jarvis up.",
+ method="PUT",
+ path="/api/settings/wake-word",
+ params={
+ "type": "object",
+ "properties": {
+ "phrase": _str_param(
+ "The new wake phrase.", min_length=1, max_length=64
+ ),
+ },
+ "required": ["phrase"],
+ },
+ ui_section="settings",
+ voice_aliases={
+ "de": ("ändere mein wake word zu nova",), # i18n-allow: STT input vocabulary
+ "en": ("change my wake word to nova",),
+ "es": ("cambia mi palabra de activación a nova",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="tts-volume-set",
+ title="Set voice volume",
+ description="Set the text-to-speech output volume (0.0 to 1.0).",
+ method="PUT",
+ path="/api/settings/tts-volume",
+ params={
+ "type": "object",
+ "properties": {
+ "volume": {
+ "type": "number", "minimum": 0.0, "maximum": 1.0,
+ "description": "Output volume between 0.0 and 1.0.",
+ },
+ "persist": {
+ "type": "boolean", "default": True,
+ "description": "Persist as boot default.",
+ },
+ },
+ "required": ["volume"],
+ },
+ ui_section="settings",
+ voice_aliases={
+ "de": ("stell die lautstärke auf 50 prozent",), # i18n-allow: STT input vocabulary
+ "en": ("set the voice volume to 50 percent",),
+ "es": ("pon el volumen de la voz al 50 por ciento",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="audio-devices-list",
+ title="List audio devices",
+ description="List available speaker and microphone devices.",
+ method="GET",
+ path="/api/settings/audio-devices",
+ ui_section="settings",
+ voice_aliases={
+ "de": ("welche audiogeräte gibt es",), # i18n-allow: STT input vocabulary
+ "en": ("list my audio devices",),
+ "es": ("qué dispositivos de audio hay",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ # ----------------------------------------------------------- system
+ AppCommand(
+ id="app-restart",
+ title="Restart Jarvis",
+ description="Restart the Jarvis desktop app (voice + UI restart too).",
+ method="POST",
+ path="/api/settings/restart-app",
+ dangerous=True,
+ ui_section="settings",
+ voice_aliases={
+ "de": ("starte jarvis neu",), # i18n-allow: STT input vocabulary
+ "en": ("restart jarvis",),
+ "es": ("reinicia jarvis",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ # ----------------------------------------------- missions & tasks
+ AppCommand(
+ id="missions-list",
+ title="List missions",
+ description="List Jarvis-Agent missions and their status.",
+ method="GET",
+ path="/api/missions",
+ ui_section="agents",
+ voice_aliases={
+ "de": ("zeig mir die missionen",), # i18n-allow: STT input vocabulary
+ "en": ("show me the missions",),
+ "es": ("muéstrame las misiones",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="mission-cancel",
+ title="Cancel a mission",
+ description="Cancel a running Jarvis-Agent mission by id.",
+ method="POST",
+ path="/api/missions/{mission_id}/cancel",
+ params={
+ "type": "object",
+ "properties": {
+ "mission_id": _str_param("Mission id to cancel.", min_length=1),
+ },
+ "required": ["mission_id"],
+ },
+ path_params=("mission_id",),
+ dangerous=True,
+ ui_section="agents",
+ voice_aliases={
+ "de": ("brich die mission ab",), # i18n-allow: STT input vocabulary
+ "en": ("cancel the mission",),
+ "es": ("cancela la misión",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="tasks-list",
+ title="List tasks",
+ description="List scheduled and running tasks.",
+ method="GET",
+ path="/api/tasks",
+ ui_section="tasks",
+ voice_aliases={
+ "de": ("zeig mir meine aufgaben",), # i18n-allow: STT input vocabulary
+ "en": ("show me my tasks",),
+ "es": ("muéstrame mis tareas",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ AppCommand(
+ id="task-cancel",
+ title="Cancel a task",
+ description="Cancel a running or scheduled task by id.",
+ method="POST",
+ path="/api/tasks/{task_id}/cancel",
+ params={
+ "type": "object",
+ "properties": {
+ "task_id": _str_param("Task id to cancel.", min_length=1),
+ },
+ "required": ["task_id"],
+ },
+ path_params=("task_id",),
+ dangerous=True,
+ ui_section="tasks",
+ voice_aliases={
+ "de": ("brich die aufgabe ab",), # i18n-allow: STT input vocabulary
+ "en": ("cancel the task",),
+ "es": ("cancela la tarea",), # i18n-allow: STT input vocabulary
+ },
+ ),
+ )
+
+
+@lru_cache(maxsize=1)
+def get_registry() -> tuple[AppCommand, ...]:
+ """The command catalog — built lazily on first access, then cached."""
+ return _build_registry()
+
+
+def get_command(command_id: str) -> AppCommand | None:
+ """Look up one command by id, or None."""
+ for cmd in get_registry():
+ if cmd.id == command_id:
+ return cmd
+ return None
+
+
+def registry_as_dicts() -> list[dict[str, Any]]:
+ """The catalog as plain dicts (route responses, docs generation)."""
+ return [cmd.as_dict() for cmd in get_registry()]
diff --git a/jarvis/ui/web/commands_routes.py b/jarvis/ui/web/commands_routes.py
new file mode 100644
index 0000000000..03d91f344e
--- /dev/null
+++ b/jarvis/ui/web/commands_routes.py
@@ -0,0 +1,37 @@
+"""REST surface for the Command Registry (``jarvis/commands/registry.py``).
+
+``GET /api/commands`` serves the one machine-readable catalog of user-facing
+app commands to the desktop UI, the ``jarvis`` CLI (through the dynamic
+OpenAPI layer), and any external agent. The registry itself is plain lazy
+in-process data (AP-26: nothing here runs at boot), so this route is cheap.
+"""
+from __future__ import annotations
+
+from typing import Any
+
+from fastapi import APIRouter
+
+router = APIRouter(prefix="/api/commands", tags=["commands"])
+
+
+async def list_commands() -> dict[str, Any]:
+ """The full command catalog: id, endpoint, params schema, danger flag,
+ UI section, and voice-alias examples per command."""
+ from jarvis.commands.registry import registry_as_dicts
+
+ commands = registry_as_dicts()
+ return {"commands": commands, "count": len(commands)}
+
+
[email protected]("/{command_id}")
+async def get_command(command_id: str) -> dict[str, Any]:
+ """One command by id (404 when unknown)."""
+ from fastapi import HTTPException
+
+ from jarvis.commands.registry import get_command as _lookup
+
+ cmd = _lookup(command_id)
+ if cmd is None:
+ raise HTTPException(status_code=404, detail=f"Unknown command id: {command_id}")
+ return cmd.as_dict()
diff --git a/jarvis/ui/web/server.py b/jarvis/ui/web/server.py
index ca91cc40df..e7f55ae883 100644
--- a/jarvis/ui/web/server.py
+++ b/jarvis/ui/web/server.py
@@ -227,6 +227,7 @@ class WebServer:
)
from .chats_routes import router as chats_router
from .cli_routes import router as cli_router
+ from .commands_routes import router as commands_router
from .drop_routes import router as drop_router
from .contacts_routes import router as contacts_router
from .control_routes import router as control_router
@@ -300,6 +301,9 @@ class WebServer:
app.include_router(skills_router)
app.include_router(docs_router)
app.include_router(cli_router)
+ # Command Registry — the one machine-readable catalog of app commands
+ # (consumed by the app-command brain tool, the UI, CLI, and docs gen).
+ app.include_router(commands_router)
app.include_router(friends_router)
app.include_router(marketplace_router)
app.state.friend_registry = None
diff --git a/tests/unit/commands/__init__.py b/tests/unit/commands/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/unit/commands/test_registry_parity.py b/tests/unit/commands/test_registry_parity.py
new file mode 100644
index 0000000000..663fad04da
--- /dev/null
+++ b/tests/unit/commands/test_registry_parity.py
@@ -0,0 +1,154 @@
+"""Parity guards for the Command Registry (the AP-4 anti-drift contract).
+
+The registry is only trustworthy if every entry stays true on three axes:
+(1) its endpoint really exists in the live OpenAPI schema, (2) its ui_section
+is a real sidebar section, (3) its danger flag is at least as strict as the
+CLI safety heuristic for the same path. These tests turn all three from
+"hopefully" into a contract.
+"""
+from __future__ import annotations
+
+import re
+
+import pytest
+from fastapi.testclient import TestClient
+
+from jarvis.commands.registry import (
+ REPLY_LANGUAGES,
+ get_command,
+ get_registry,
+ registry_as_dicts,
+)
+
+_KEBAB = re.compile(r"^[a-z][a-z0-9]*(-[a-z0-9]+)*$")
+_PLACEHOLDER = re.compile(r"\{([^}]+)\}")
+
+
+def _openapi_paths() -> dict:
+ from jarvis.core.bus import EventBus
+ from jarvis.core.config import JarvisConfig
+ from jarvis.ui.web.server import WebServer
+
+ cfg = JarvisConfig()
+ cfg.ui.dev_mode = True
+ server = WebServer(cfg, bus=EventBus())
+ return server.app.openapi()["paths"]
+
+
+def test_ids_are_unique_and_kebab_case() -> None:
+ ids = [c.id for c in get_registry()]
+ assert len(ids) == len(set(ids)), "duplicate command ids"
+ for cid in ids:
+ assert _KEBAB.match(cid), f"command id {cid!r} is not kebab-case"
+
+
+def test_every_command_endpoint_exists_in_openapi() -> None:
+ """A registry entry pointing at a missing/renamed route is a defect —
+ the exact drift class this registry exists to eliminate."""
+ paths = _openapi_paths()
+ for cmd in get_registry():
+ assert cmd.path in paths, (
+ f"{cmd.id}: path {cmd.path!r} is not a mounted route"
+ )
+ assert cmd.method.lower() in paths[cmd.path], (
+ f"{cmd.id}: {cmd.method} not offered on {cmd.path!r} "
+ f"(has: {sorted(paths[cmd.path])})"
+ )
+
+
+def test_every_ui_section_is_a_real_sidebar_section() -> None:
+ from jarvis.plugins.tool.navigate import KNOWN
+
+ for cmd in get_registry():
+ assert cmd.ui_section in KNOWN, (
+ f"{cmd.id}: ui_section {cmd.ui_section!r} is not a sidebar section"
+ )
+
+
+def test_params_schemas_are_wellformed_objects() -> None:
+ for cmd in get_registry():
+ if not cmd.params:
+ continue
+ assert cmd.params.get("type") == "object", f"{cmd.id}: params not an object"
+ props = cmd.params.get("properties", {})
+ assert isinstance(props, dict)
+ for req in cmd.params.get("required", []):
+ assert req in props, f"{cmd.id}: required {req!r} missing in properties"
+ # Every path placeholder must be a declared path param AND a property.
+ placeholders = set(_PLACEHOLDER.findall(cmd.path))
+ assert placeholders == set(cmd.path_params), (
+ f"{cmd.id}: path placeholders {placeholders} != path_params "
+ f"{set(cmd.path_params)}"
+ )
+ for p in cmd.path_params:
+ assert p in props, f"{cmd.id}: path param {p!r} missing in properties"
+
+
+def test_danger_flags_at_least_as_strict_as_cli_heuristic() -> None:
+ """The CLI's method+path heuristic is the floor: anything IT calls
+ destructive must be dangerous here too (the registry may be stricter)."""
+ from jarvis.cli_ctl import safety
+
+ for cmd in get_registry():
+ if safety.is_dangerous(cmd.method, cmd.path):
+ assert cmd.dangerous, (
+ f"{cmd.id}: {cmd.method} {cmd.path} is dangerous per the CLI "
+ "heuristic but not flagged dangerous in the registry"
+ )
+
+
+def test_reply_languages_match_brain_source_of_truth() -> None:
+ from jarvis.brain.manager import SUPPORTED_REPLY_LANGUAGES
+
+ assert REPLY_LANGUAGES == SUPPORTED_REPLY_LANGUAGES
+
+
+def test_brain_switch_enum_excludes_subagent_only_providers() -> None:
+ """codex/antigravity are brain_switchable=False — the LLM must never even
+ see them as valid brain-switch targets."""
+ cmd = get_command("brain-switch")
+ assert cmd is not None
+ enum = cmd.params["properties"]["provider"].get("enum") or []
+ assert enum, "brain-switch provider enum missing (catalog import failed?)"
+ assert "codex" not in enum
+ assert "antigravity" not in enum
+
+
+def test_registry_served_over_rest() -> None:
+ from jarvis.core.bus import EventBus
+ from jarvis.core.config import JarvisConfig
+ from jarvis.ui.web.server import WebServer
+
+ cfg = JarvisConfig()
+ cfg.ui.dev_mode = True
+ server = WebServer(cfg, bus=EventBus())
+ with TestClient(server.app) as client:
+ resp = client.get("/api/commands")
+ assert resp.status_code == 200
+ body = resp.json()
+ assert body["count"] == len(get_registry())
+ assert {c["id"] for c in body["commands"]} == {c.id for c in get_registry()}
+
+ one = client.get("/api/commands/brain-switch")
+ assert one.status_code == 200
+ assert one.json()["path"] == "/api/brain/switch"
+
+ missing = client.get("/api/commands/does-not-exist")
+ assert missing.status_code == 404
+
+
+def test_registry_dicts_are_json_serializable_and_small() -> None:
+ import json
+
+ payload = json.dumps(registry_as_dicts(), ensure_ascii=False)
+ # "Simple storage": the whole catalog must stay small (target << 100 KB).
+ assert len(payload.encode("utf-8")) < 100_000
+
+
[email protected]("locale", ["de", "en", "es"])
+def test_every_command_has_voice_aliases_for_all_supported_locales(locale) -> None:
+ """Supported languages are equal (CLAUDE.md §1) — no de/en-only bias."""
+ for cmd in get_registry():
+ assert cmd.voice_aliases.get(locale), (
+ f"{cmd.id}: missing {locale} voice alias"
+ )