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(skills): deterministic capture when the user names a skill

rubenluetke10-beep64e869ddf917
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index f6e1de9186..81763ad13a 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -4958,6 +4958,37 @@ class BrainManager:
if ctx is None:
return None
+ # Channel 0 (2026-08-12): the user NAMED a skill ("nutz den Skill
+ # X"). autofire_policy sanctions exactly this as the human path to
+ # any skill class, so it resolves deterministically and inherits
+ # trigger-grade rights — the prompt-only version of this promise
+ # converted to zero invocations in 14 live days. Still subject to
+ # the block-tier guard below via the shared decision flow.
+ from jarvis.skills.explicit_request import (
+ resolve_explicit_skill_request,
+ )
+
+ explicit = resolve_explicit_skill_request(user_text, ctx.registry)
+ if explicit is not None:
+ explicit_skill, explicit_decision = explicit
+ if self._skill_is_blocked(explicit_skill):
+ log.info(
+ "explicitly named skill %s is block-tier — not captured",
+ getattr(explicit_skill, "name", "?"),
+ )
+ self._record_skill_decision(
+ user_text, explicit_decision, lang=lang,
+ vetoed_by=guards.VETO_BLOCK_TIER, skill=explicit_skill,
+ )
+ return None
+ self._skill_match_band = explicit_decision.band
+ self._skill_match_class = classify(explicit_skill)
+ self._record_skill_decision(
+ user_text, explicit_decision, lang=lang,
+ skill=explicit_skill, fired=True,
+ )
+ return explicit_skill
+
cfg = self._skills_config()
decision = match_eval.evaluate_match(
ctx.registry,
diff --git a/jarvis/skills/explicit_request.py b/jarvis/skills/explicit_request.py
new file mode 100644
index 0000000000..f3acad97f9
--- /dev/null
+++ b/jarvis/skills/explicit_request.py
@@ -0,0 +1,144 @@
+"""Deterministic resolution of "use the skill X" — the user named it.
+
+The doctrine in :mod:`jarvis.skills.autofire_policy` reserves two sanctioned
+paths for a dispatching-class skill: the model asks via ``run-skill``, or THE
+USER NAMES IT. Before this module the second path was prompt-only — the
+pc-control gate kept ``run-skill`` visible when the word "skill" appeared, and
+everything after that was hope that a fast router model makes the call. Live
+telemetry (14 days, 2026-08-12 rework) measured that hope at zero calls.
+
+This resolver closes that gap deterministically, in the same spirit as the
+author-regex trigger channel: pure CPU, no LLM, no IO (AP-9/AP-11 safe), and
+precision over recall. It fires only when ALL THREE hold:
+
+1. an explicit use-verb ("nutz", "starte", "run", "use", "ejecuta", …),
+2. the literal word "skill(s)" — the user is talking about the mechanism,
+3. an installed, active skill whose NAME is spoken in the utterance.
+
+"Welche skills habe ich?" has no use-verb; "erstell mir einen skill …" has no
+resolvable installed name; "starte die morgenroutine" has no "skill" word and
+stays with the trigger/relevance channels. All three miss here by design.
+
+Name matching is speech-tolerant: kebab-case names are compared as normalized
+token sequences ("morning-routine" ↔ "morning routine"), and the namespace
+prefixes ``plugin-`` / ``cli-`` may be omitted ("use the gmail skill" resolves
+``plugin-gmail``). The longest spoken name wins so "focus pro" never resolves
+to a skill called "focus".
+"""
+from __future__ import annotations
+
+import re
+from typing import Any
+
+from jarvis.skills.match_eval import (
+ BAND_FIRE,
+ SOURCE_TRIGGER,
+ TRIGGER_MATCH_SCORE,
+ MatchCandidate,
+ MatchDecision,
+)
+from jarvis.skills.relevance import normalize_text
+
+#: Imperative use-verbs in DE / EN / ES, matched against the RAW utterance
+#: (umlaut and digraph forms both listed). Deliberately excludes authoring
+#: verbs ("erstell", "bau", "create") — creating a skill is not running one.
+_EXPLICIT_VERB_RE = re.compile(
+ r"\b("
+ r"nutz(?:e|t)?|benutz(?:e|t)?|verwende?|starte?|" # i18n-allow: speech-input vocabulary
+ r"f[üu]hr(?:e|t)?|fuehre?|aktiviere?|" # i18n-allow: speech-input vocabulary
+ r"run|use|execute|launch|trigger|invoke|activate|start|"
+ r"usa|ejecuta|lanza|activa" # i18n-allow: speech-input vocabulary
+ r")\b",
+ re.IGNORECASE,
+)
+
+#: The user must literally say "skill(s)" — same word DE/EN/ES. Mirrors the
+#: pc-control gate's ``_EXPLICIT_SKILL_REQUEST_RE`` in the brain manager.
+_SKILL_WORD_RE = re.compile(r"\bskills?\b", re.IGNORECASE)
+
+#: Namespace prefixes a speaker naturally drops ("the gmail skill").
+_DROPPABLE_NAME_PREFIXES = frozenset({"plugin", "cli"})
+
+_TOKEN_RE = re.compile(r"[a-z0-9]+")
+
+
+def _name_token_sequences(name: str) -> list[tuple[str, ...]]:
+ """Spoken token sequences under which a skill name is recognized."""
+ tokens = tuple(t for t in _TOKEN_RE.findall(normalize_text(name)) if t)
+ if not tokens:
+ return []
+ sequences = [tokens]
+ if len(tokens) > 1 and tokens[0] in _DROPPABLE_NAME_PREFIXES:
+ sequences.append(tokens[1:])
+ return sequences
+
+
+def _contains_sequence(haystack: tuple[str, ...], needle: tuple[str, ...]) -> bool:
+ """True when ``needle`` appears as a CONTIGUOUS run inside ``haystack``."""
+ if not needle or len(needle) > len(haystack):
+ return False
+ for start in range(len(haystack) - len(needle) + 1):
+ if haystack[start : start + len(needle)] == needle:
+ return True
+ return False
+
+
+def resolve_explicit_skill_request(
+ utterance: str, registry: Any
+) -> tuple[Any, MatchDecision] | None:
+ """Resolve "use the skill X" to the installed skill the user named.
+
+ Returns ``(skill, decision)`` — the decision carries ``SOURCE_TRIGGER``
+ on purpose: a spoken name is the same grade of evidence as an author's
+ trigger phrase (the user stated intent verbatim), so it inherits the
+ trigger channel's unconditional capture and its full stand-down rights.
+ Returns ``None`` on any miss. Never raises.
+ """
+ if not utterance or registry is None:
+ return None
+ try:
+ if not _SKILL_WORD_RE.search(utterance):
+ return None
+ if not _EXPLICIT_VERB_RE.search(utterance):
+ return None
+ spoken = tuple(_TOKEN_RE.findall(normalize_text(utterance)))
+ if not spoken:
+ return None
+
+ best: tuple[int, str, Any] | None = None # (match_len, name, skill)
+ for skill in registry.list_active():
+ name = str(getattr(skill, "name", "") or "")
+ if not name:
+ continue
+ for sequence in _name_token_sequences(name):
+ if not _contains_sequence(spoken, sequence):
+ continue
+ # Longest spoken sequence wins; ties break on the name for
+ # determinism regardless of registry iteration order.
+ key = (len(sequence), name)
+ if best is None or key > (best[0], best[1]):
+ best = (len(sequence), name, skill)
+ if best is None:
+ return None
+
+ _, name, skill = best
+ candidate = MatchCandidate(
+ skill_name=name,
+ score=TRIGGER_MATCH_SCORE,
+ band=BAND_FIRE,
+ source=SOURCE_TRIGGER,
+ evidence=name,
+ reason=f"user explicitly requested skill {name!r} by name",
+ )
+ decision = MatchDecision(
+ band=BAND_FIRE,
+ source=SOURCE_TRIGGER,
+ top=candidate,
+ candidates=(candidate,),
+ )
+ return skill, decision
+ except Exception: # noqa: BLE001 — resolution must never break a turn
+ return None
+
+
+__all__ = ["resolve_explicit_skill_request"]
diff --git a/tests/unit/brain/test_skill_relevance_routing.py b/tests/unit/brain/test_skill_relevance_routing.py
index fb558245a4..63236e501e 100644
--- a/tests/unit/brain/test_skill_relevance_routing.py
+++ b/tests/unit/brain/test_skill_relevance_routing.py
@@ -602,3 +602,50 @@ def test_matching_never_raises_without_a_skill_context() -> None:
"""Headless and mock boots have no skill subsystem at all."""
manager = _make_manager()
assert manager._match_skill_for_turn(FIRE_UTTERANCE) is None
+
+
+# ---------------------------------------------------------------------------
+# Channel 0: the user names the skill (2026-08-12)
+# ---------------------------------------------------------------------------
+
+
+def test_an_explicitly_named_mission_skill_captures(tmp_path: Path) -> None:
+ """Naming a skill is the sanctioned human path to a dispatching skill.
+
+ The relevance channel must never start a background worker
+ (class_dispatching veto), but "nutz den Skill cloud-debug" states intent
+ verbatim — it captures with trigger-grade rights.
+ """
+ _write_skill(
+ tmp_path,
+ "cloud-debug",
+ description="Dispatch a bug hunt to the background worker.",
+ execution="mission",
+ )
+ for filler in range(6):
+ _write_skill(tmp_path, f"filler-{filler}", description=f"topic{filler}")
+ _install(tmp_path)
+
+ manager = _make_manager()
+ matched = manager._match_skill_for_turn("nutz den skill cloud-debug") # i18n-allow
+ assert matched is not None
+ assert matched.name == "cloud-debug"
+ assert manager._skill_relevance is None, "explicit naming has trigger rights"
+
+ entry = match_log.recent(1)[0]
+ assert entry.fired is True
+ assert entry.source == "trigger"
+
+
+def test_an_explicitly_named_block_tier_skill_stays_blocked(
+ tmp_path: Path,
+) -> None:
+ """block > everything: even a spoken name does not unlock a blocked skill."""
+ _write_skill(tmp_path, "locked", tier="block")
+ for filler in range(6):
+ _write_skill(tmp_path, f"filler-{filler}", description=f"topic{filler}")
+ _install(tmp_path)
+
+ manager = _make_manager()
+ assert manager._match_skill_for_turn("use the skill locked") is None
+ assert match_log.recent(1)[0].vetoed_by == "block_tier"
diff --git a/tests/unit/skills/test_explicit_request.py b/tests/unit/skills/test_explicit_request.py
new file mode 100644
index 0000000000..2be9834879
--- /dev/null
+++ b/tests/unit/skills/test_explicit_request.py
@@ -0,0 +1,138 @@
+"""Unit tests for ``jarvis.skills.explicit_request``.
+
+The resolver is the deterministic form of the doctrine in
+``autofire_policy``: the user naming a skill is a sanctioned path to ANY
+skill class. Precision over recall — every test in the "misses" section is a
+hard negative that must never resolve.
+
+Lightweight fakes, no ``unittest.mock`` (CLAUDE.md testing convention).
+"""
+from __future__ import annotations
+
+from dataclasses import dataclass, field
+
+from jarvis.skills.explicit_request import resolve_explicit_skill_request
+from jarvis.skills.match_eval import BAND_FIRE, SOURCE_TRIGGER
+
+
+@dataclass
+class _FakeSkill:
+ name: str
+ frontmatter: object | None = None
+ state: str = "validated"
+ body: str = ""
+ resources: dict = field(default_factory=dict)
+
+
+class _FakeRegistry:
+ def __init__(self, names: list[str]) -> None:
+ self._skills = [_FakeSkill(name=n) for n in names]
+
+ def list_active(self) -> list[_FakeSkill]:
+ return list(self._skills)
+
+
+_REGISTRY = _FakeRegistry([
+ "morning-routine",
+ "deep-work-mode",
+ "plugin-gmail",
+ "cli-gcloud",
+ "focus",
+ "focus-pro",
+])
+
+
+# ---------------------------------------------------------------------------
+# Hits
+# ---------------------------------------------------------------------------
+
+
+def test_german_use_verb_and_kebab_name() -> None:
+ hit = resolve_explicit_skill_request(
+ "nutz den skill morning-routine bitte", _REGISTRY # i18n-allow
+ )
+ assert hit is not None
+ skill, decision = hit
+ assert skill.name == "morning-routine"
+ assert decision.band == BAND_FIRE
+ assert decision.source == SOURCE_TRIGGER
+
+
+def test_spoken_name_without_hyphens_resolves() -> None:
+ hit = resolve_explicit_skill_request(
+ "Jarvis, starte den Skill Morning Routine", _REGISTRY # i18n-allow
+ )
+ assert hit is not None
+ assert hit[0].name == "morning-routine"
+
+
+def test_namespace_prefix_may_be_dropped() -> None:
+ hit = resolve_explicit_skill_request("use the gmail skill", _REGISTRY)
+ assert hit is not None
+ assert hit[0].name == "plugin-gmail"
+
+
+def test_cli_prefix_may_be_dropped() -> None:
+ hit = resolve_explicit_skill_request("run the gcloud skill", _REGISTRY)
+ assert hit is not None
+ assert hit[0].name == "cli-gcloud"
+
+
+def test_longest_spoken_name_wins() -> None:
+ """"focus pro" must never resolve to the shorter skill "focus"."""
+ hit = resolve_explicit_skill_request(
+ "execute the skill focus pro now", _REGISTRY
+ )
+ assert hit is not None
+ assert hit[0].name == "focus-pro"
+
+
+def test_umlaut_verb_form_resolves() -> None:
+ hit = resolve_explicit_skill_request(
+ "führe den skill deep-work-mode aus", _REGISTRY # i18n-allow
+ )
+ assert hit is not None
+ assert hit[0].name == "deep-work-mode"
+
+
+# ---------------------------------------------------------------------------
+# Misses — every one of these firing would be an over-fire
+# ---------------------------------------------------------------------------
+
+
+def test_listing_question_has_no_use_verb() -> None:
+ assert resolve_explicit_skill_request(
+ "welche skills habe ich eigentlich", _REGISTRY # i18n-allow
+ ) is None
+
+
+def test_authoring_request_names_no_installed_skill() -> None:
+ assert resolve_explicit_skill_request(
+ "erstell mir einen skill der jeden morgen die mails vorliest", # i18n-allow
+ _REGISTRY,
+ ) is None
+
+
+def test_missing_skill_word_stays_with_the_other_channels() -> None:
+ """"starte die morning routine" is trigger/relevance territory."""
+ assert resolve_explicit_skill_request(
+ "starte die morning routine", _REGISTRY # i18n-allow
+ ) is None
+
+
+def test_unknown_name_resolves_nothing() -> None:
+ assert resolve_explicit_skill_request(
+ "run the skill quarterly-report", _REGISTRY
+ ) is None
+
+
+def test_partial_namespaced_name_does_not_match() -> None:
+ """"plugin" alone is not a name; only the full or prefix-dropped form is."""
+ assert resolve_explicit_skill_request(
+ "use the plugin skill", _REGISTRY
+ ) is None
+
+
+def test_empty_and_none_inputs() -> None:
+ assert resolve_explicit_skill_request("", _REGISTRY) is None
+ assert resolve_explicit_skill_request("use the gmail skill", None) is None