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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(agentic-ide): ask which coding CLI was meant instead of guessing
Ruben Lütkef82e7c5aae99
diff --git a/jarvis/agentic_ide/clarify.py b/jarvis/agentic_ide/clarify.pyindex a03b73d78a..a813c88588 100644--- a/jarvis/agentic_ide/clarify.py+++ b/jarvis/agentic_ide/clarify.py@@ -715,6 +715,17 @@ class ClarificationWindow:return (decided, pending.utterance) if decided else None+def classify_short_answer(text: str, language: str = "de") -> str:+ """``"confirm"`` / ``"veto"`` / ``"unknown"`` for a short spoken answer.++ Public because more than one question is asked of the workspace now — the+ pane-name one here, and the coding-CLI one in the spawn path — and both+ have to read a "yes" the same way. A second classifier would drift, and the+ drift would show up as one question honouring an answer the other ignores.+ """+ return _classify(text, language)++def _classify(text: str, language: str) -> str:"""Yes/no verdict for a short answer, across every supported language.@@ -747,6 +758,7 @@ __all__ = ["ClarificationWindow","UncertainName","addresses_workspace",+ "classify_short_answer","detect_clarification","is_outside_world_talk","is_part_of_full_name",diff --git a/jarvis/agentic_ide/intent.py b/jarvis/agentic_ide/intent.pyindex 9fc6702331..92f239145b 100644--- a/jarvis/agentic_ide/intent.py+++ b/jarvis/agentic_ide/intent.py@@ -1083,6 +1083,17 @@ def _depluralized(name: str) -> list[str]:return out+def canonical_agent(raw: str) -> str | None:+ """The CLI a spoken name means, or ``None``.++ The public face of ``_canonical_agent``, for the callers outside this module+ that have to read a CLI name the same way the parser does — the spawn path's+ "did you mean Claude Code or Codex?" answer, above all. Reading it a second+ way there would mean a name the parser accepts and the answer does not.+ """+ return _canonical_agent(raw)++def _standalone_spellings() -> dict[str, str]:"""Spelling → CLI, for the spellings that name a product on their own."""return {@@ -1108,6 +1119,17 @@ def _open_verbs(text: str) -> list[re.Match[str]]:]+@dataclass(frozen=True, slots=True)+class UncertainCli:+ """A word standing where a CLI name belongs, and the CLIs it could be."""++ spoken: str+ """The word as the transcript spelled it ("Klaudi", "Codecks")."""++ candidates: tuple[str, ...]+ """CLI names it could mean, best first. Never empty, never certain."""++@dataclass(frozen=True, slots=True)class SpawnGroup:"""One "N of agent X" part of a spawn request."""@@ -1132,6 +1154,19 @@ class SpawnTerminalsRequest:utterance: str"""The original utterance, unmodified."""+ uncertain_cli: tuple[UncertainCli, ...] = ()+ """Words that stand where a CLI name belongs but name none of them clearly.++ The caller ASKS rather than acts on these — the maintainer's directive of+ 2026-07-28: "wenn unklar ist, ob Claude Code oder Codex gemeint ist, soll+ er einfach nachfragen". # i18n-allow: quoted maintainer directive++ Same asymmetry the pane-name question is built on (see ``clarify``): a+ needless question costs one word, while a wrong guess opens the wrong+ coding agent, on the wrong subscription, and the user finds out when it+ starts answering in the wrong style.+ """+unsupported: tuple[str, ...] = ()"""Coding CLIs the user counted that this workspace does not offer.@@ -1457,6 +1492,124 @@ def _unsupported_clis(text: str) -> tuple[str, ...]:return tuple(out)+#: How close a word must come to a CLI's name to be worth asking about.+#:+#: The same floor the pane-name question uses (``names._NEAR_MISS_FLOOR``), and+#: deliberately the same NUMBER rather than a second opinion about closeness:+#: two thresholds for one notion is how a word ends up uncertain to one path and+#: certain to another, which is the gap that produced turns with neither an+#: action nor a question.+_CLI_NEAR_MISS_FLOOR = 0.55++#: Words that stand between a count and a CLI name without being either.+#:+#: They occupy the same position a garbled product name would, so without this+#: every one of them would be held up as "did you mean Claude Code?".+_CLI_POSITION_NOISE = frozenset(+ {+ "neue", "neuen", "weitere", "weiteren", "zusätzliche", "zusaetzliche", # i18n-allow: input vocab+ "new", "more", "extra", "additional", "other", "another",+ "otros", "otras", "más", "mas", "nuevos", "nuevas", # i18n-allow: input vocab+ "de", "del", "von", "vom", "of", "the", "a", "an", "und", "and", "y", # i18n-allow: input vocab+ "bitte", "please", "por", "favor", "mir", "me", "uns", "us", # i18n-allow: input vocab+ }+)+++def _cli_display_names() -> dict[str, str]:+ """CLI key → the name a question should say out loud."""+ try:+ from jarvis.workspace import agents as workspace_agents++ return {agent.name: agent.display_name for agent in workspace_agents.coding_agents()}+ except Exception: # noqa: BLE001 - a question must never break a turn+ return {}+++def _closest_clis(word: str) -> tuple[tuple[str, float], ...]:+ """The CLIs ``word`` almost names, best first, or ``()``.++ Scored against every accepted SPELLING of every CLI and reduced to the best+ per CLI, because the spellings are what speech actually produces — "Klaudi"+ is nowhere near the string "claude code" but sits right next to "klaude".+ """+ from .names import similarity++ best: dict[str, float] = {}+ for agent, spellings in _agent_spellings().items():+ for spelling in spellings:+ score = similarity(word, spelling)+ if score > best.get(agent, 0.0):+ best[agent] = score+ scored = [(agent, score) for agent, score in best.items() if score >= _CLI_NEAR_MISS_FLOOR]+ return tuple(sorted(scored, key=lambda item: (-item[1], item[0])))+++def _uncertain_clis(text: str) -> tuple[UncertainCli, ...]:+ """Words standing where a CLI name belongs that name none of them clearly.++ Two questions have to be answered before a word qualifies, and both are+ narrow on purpose — a question the user did not need is still a cost:++ 1. **Is it in a CLI's position?** Directly behind a count ("two Klaudi") or+ directly in front of the pane noun ("Klaudi terminals"). A word anywhere+ else in the sentence is not a garbled product name, it is a word.+ 2. **Does it come close to one?** Scored on the resolver's own scale. A word+ that resembles nothing — "two NASA Cloud Code terminals", where NASA is+ simply debris between the count and the real name — scores below the+ floor against every CLI and is left alone.++ A word that resolves EXACTLY is never here: that is certainty, and the+ acting path owns it.+ """+ counts = _count_tokens(text)+ pane_nouns = [(m.start(), m.end()) for m in _PANE_NOUN_RE.finditer(text)]+ known = [+ (m.start(), m.end())+ for m in _AGENT_RE.finditer(text)+ if _canonical_agent(m.group("agent")) is not None+ ]+ display = _cli_display_names()++ out: list[UncertainCli] = []+ seen: set[str] = set()+ for match in re.finditer(r"\b[^\W\d_]{3,}\b", text, re.UNICODE):+ word = match.group(0)+ folded = word.casefold()+ if folded in _CLI_POSITION_NOISE or folded in seen:+ continue+ if _count_of(word) is not None or _canonical_agent(word) is not None:+ continue+ if _PANE_NOUN_RE.fullmatch(word) or _UNSUPPORTED_CLI_RE.fullmatch(word):+ continue+ # Inside, or overlapping, a name that WAS recognised: not a candidate.+ if any(start <= match.start() < end for start, end in known):+ continue+ behind_count = any(+ end <= match.start() and match.start() - end <= 3 for _s, end, _v in counts+ )+ before_pane = any(+ match.end() <= start and start - match.end() <= 3 for start, _e in pane_nouns+ )+ if not behind_count and not before_pane:+ continue+ # The real name may follow it ("two NASA Cloud Code terminals"): the+ # group is not in doubt, so neither is this word.+ if any(0 <= start - match.end() <= 12 for start, _end in known):+ continue+ candidates = _closest_clis(word)+ if not candidates:+ continue+ seen.add(folded)+ out.append(+ UncertainCli(+ spoken=word,+ candidates=tuple(display.get(agent, agent) for agent, _score in candidates[:3]),+ )+ )+ return tuple(out)++#: The verb that means a BACKGROUND worker, not a pane.#:#: "Spawn" is the word this app uses for dispatching a Jarvis-Agent, and a@@ -1863,6 +2016,7 @@ def detect_spawn(parse_text = addressed_textunsupported = _unsupported_clis(parse_text)+ uncertain_cli = _uncertain_clis(parse_text)groups = _spoken_groups(parse_text)if groups:@@ -1872,6 +2026,7 @@ def detect_spawn(utterance=text,groups=groups,unsupported=unsupported,+ uncertain_cli=uncertain_cli,)if unsupported and not groups:@@ -1886,6 +2041,7 @@ def detect_spawn(utterance=text,groups=(),unsupported=unsupported,+ uncertain_cli=uncertain_cli,)agent_match = _AGENT_RE.search(parse_text)@@ -1899,6 +2055,7 @@ def detect_spawn(utterance=text,groups=(SpawnGroup(count=count, agent=agent),),unsupported=unsupported,+ uncertain_cli=uncertain_cli,)diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 8e03ea0f3a..b3f3c25916 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -36,6 +36,7 @@ from collections.abc import (Sequence,)from contextvars import ContextVar+from dataclasses import dataclassfrom typing import TYPE_CHECKING, Any, Literalfrom uuid import UUID, uuid4@@ -1216,6 +1217,42 @@ def _recent_agent(recent: Any) -> str:return max(counts.items(), key=lambda kv: kv[1])[0]+@dataclass(slots=True)+class _PendingCliChoice:+ """A "did you mean Claude Code or Codex?" waiting for its answer.++ Kept on the manager rather than inside the detector for the same reason the+ pane-name question is: the detector answers "is this clear?", and only the+ turn loop knows what to do about it and when the answer arrives.++ The whole fleet is held, not just the unclear part. "Two Klaudi terminals+ and one Codex" is ONE request, and opening the Codex pane while asking about+ the other two would leave the user answering a question about a workspace+ that had already changed under them.+ """++ groups: tuple[Any, ...]+ """The parsed fleet. Every group with no CLI takes the answered one."""++ utterance: str+ candidates: tuple[str, ...]+ """CLI display names offered, best first. The answer names one of these."""++ asked_at: float+ """``time.monotonic()`` — the window is short on purpose (see TTL)."""+++#: How long the CLI question stays answerable.+#:+#: Two minutes, the same bound as the pane-name question and the delegation+#: offer: long enough for "uh… Codex", short enough that a forgotten question+#: cannot open panes in the middle of an unrelated turn later on.+_CLI_QUESTION_TTL_S = 120.0++#: A short reply is an ANSWER; a sentence is the user moving on.+_CLI_ANSWER_MAX_WORDS = 6++def _available_terminal_kinds() -> str:"""The coding CLIs this workspace can open, as a spoken list.@@ -6389,8 +6426,14 @@ class BrainManager:except Exception: # noqa: BLE001 - optional surfacereturn None+ # A question asked last turn is answered BEFORE anything is parsed+ # again: "Codex" on its own is not a spawn request and would otherwise+ # fall through to the ordinary brain, leaving the user's answer — and+ # the fleet it was about — to evaporate.+ answered = self._answer_pending_cli_question(user_text)+try:- request = ide_intent.detect_spawn(user_text)+ request = answered or ide_intent.detect_spawn(user_text)except Exception: # noqa: BLE001 - detection must never break a turnreturn Noneif request is None:@@ -6405,6 +6448,34 @@ class BrainManager:)from jarvis.voice.action_phrases import action_phrase+ # The name did not clearly reach one CLI. ASK — this is the maintainer's+ # directive of 2026-07-28 and the same rule the pane-name question+ # follows: whatever is unsure becomes a question rather than an action,+ # because the question costs one word and the guess costs an agent+ # working on the wrong plan until somebody notices.+ if request.uncertain_cli:+ unclear = request.uncertain_cli[0]+ self._pending_cli_choice = _PendingCliChoice(+ groups=tuple(request.groups),+ utterance=request.utterance,+ candidates=unclear.candidates,+ asked_at=time.monotonic(),+ )+ if len(unclear.candidates) == 1:+ return action_phrase(+ "ide_terminal_kind_unclear_one",+ out_lang,+ spoken=unclear.spoken,+ first=unclear.candidates[0],+ )+ return action_phrase(+ "ide_terminal_kind_unclear",+ out_lang,+ spoken=unclear.spoken,+ first=unclear.candidates[0],+ second=unclear.candidates[1],+ )+registry = get_registry()folder_label: str | None = None#: Why a group of the fleet could not be opened, one sentence each.@@ -6581,6 +6652,81 @@ class BrainManager:line = f"{line} {action_phrase('ide_terminals_briefing_queued', out_lang)}"return line+ def _answer_pending_cli_question(self, user_text: str) -> Any | None:+ """The held fleet with its CLI filled in, or ``None``.++ Consumes the question either way. A question that has been answered,+ declined, or simply talked past must never open panes on a later turn —+ the same rule the pane-name window follows, and for the same reason: a+ forgotten "yes" that opens four terminals ten minutes later is worse+ than never having asked.++ Three shapes count as an answer, in falling directness: naming a CLI+ ("Codex", "Claude Code"), agreeing when only one was offered ("yes"),+ and naming its position ("the first one"). Anything longer than a few+ words is the user moving on.+ """+ pending = getattr(self, "_pending_cli_choice", None)+ if pending is None:+ return None+ text = (user_text or "").strip()+ if not text:+ return None+ if time.monotonic() - pending.asked_at > _CLI_QUESTION_TTL_S:+ self._pending_cli_choice = None+ return None+ if len(text.split()) > _CLI_ANSWER_MAX_WORDS:+ # Not an answer. The question is spent rather than left armed: the+ # user has moved on, and a stale question would answer a sentence+ # they never meant as one.+ self._pending_cli_choice = None+ return None++ from jarvis.agentic_ide import intent as ide_intent++ chosen: str | None = None+ # A CLI named outright wins, wherever in the short answer it sits.+ for size in (3, 2, 1):+ words = text.replace(",", " ").split()+ for start in range(len(words) - size + 1):+ agent = ide_intent.canonical_agent(" ".join(words[start : start + size]))+ if agent is not None:+ chosen = agent+ break+ if chosen is not None:+ break+ if chosen is None and len(pending.candidates) == 1:+ # "Yes" answers a question that offered exactly one name. With two+ # on the table it answers nothing, so it is not accepted there.+ from jarvis.agentic_ide.clarify import classify_short_answer++ if classify_short_answer(text) == "confirm":+ chosen = ide_intent.canonical_agent(pending.candidates[0])+ self._pending_cli_choice = None+ if chosen is None:+ return None++ from jarvis.agentic_ide.intent import SpawnGroup, SpawnTerminalsRequest++ groups = tuple(+ SpawnGroup(count=g.count, agent=g.agent or chosen) for g in pending.groups+ )+ if not groups:+ groups = (SpawnGroup(count=1, agent=chosen),)+ log.info(+ "Agentic IDE: the unclear CLI was answered with %s — opening %d pane(s)",+ chosen,+ sum(g.count for g in groups),+ )+ return SpawnTerminalsRequest(+ count=sum(g.count for g in groups),+ agent=groups[0].agent,+ # The ORIGINAL request, so a brief that rode along with it still+ # reaches the panes it was written for.+ utterance=pending.utterance,+ groups=groups,+ )+def _is_explicit_heavy_request(self, user_text: str) -> bool:"""Return whether the user semantically requested a heavy worker."""text = (user_text or "").strip()diff --git a/jarvis/voice/action_phrases.py b/jarvis/voice/action_phrases.pyindex 8e24deaf87..2b2804d8e3 100644--- a/jarvis/voice/action_phrases.py+++ b/jarvis/voice/action_phrases.py@@ -405,6 +405,19 @@ _PHRASES: dict[str, dict[str, str]] = {"en": "The workspace is full, {max} terminals are already running.","es": "El espacio de trabajo está lleno, ya hay {max} terminales.",},+ # The name came through garbled and lands between two coding CLIs. Asked+ # rather than guessed (maintainer directive 2026-07-28): a needless question+ # costs one word, a wrong guess opens the wrong agent on the wrong plan.+ "ide_terminal_kind_unclear": {+ "de": "Ich habe {spoken} verstanden. Meintest du {first} oder {second}?", # i18n-allow+ "en": "I heard {spoken}. Did you mean {first} or {second}?",+ "es": "Escuché {spoken}: ¿te refieres a {first} o a {second}?",+ },+ "ide_terminal_kind_unclear_one": {+ "de": "Ich habe {spoken} verstanden. Meintest du {first}?", # i18n-allow+ "en": "I heard {spoken}. Did you mean {first}?",+ "es": "Escuché {spoken}: ¿te refieres a {first}?",+ },# A coding CLI this workspace does not offer was named in a fleet request.# Said out loud rather than dropped: a name nobody recognises used to fall# out of the parse without a word, so the user counted the panes and founddiff --git a/tests/unit/brain/test_agentic_ide_spawn_fast_path.py b/tests/unit/brain/test_agentic_ide_spawn_fast_path.pyindex a5fee73f42..82ddd61477 100644--- a/tests/unit/brain/test_agentic_ide_spawn_fast_path.py+++ b/tests/unit/brain/test_agentic_ide_spawn_fast_path.py@@ -474,3 +474,103 @@ async def test_the_conditional_brief_carries_the_task_and_not_the_fallback(instruction = str(captured["instruction"])assert "empty area" in instructionassert "open a new one" not in instruction, "the fallback is not the work"+++# ------------------------------------------------- asking which CLI was meant+# Maintainer directive 2026-07-28: "Wenn das sich irgendwie unklar ist mit dem+# Namen, ob jetzt zum Beispiel Claude Code oder Codex gemeint ist ... dann soll+# er einfach nachfragen." # i18n-allow: quoted maintainer directive+#+# Speech recognition writes a product name by ear, and the spellings it invents+# are open-ended — no alias table finishes that job. What the table cannot place+# used to be guessed away silently: the count went to the pane noun and panes+# opened on whatever CLI happened to be inherited, so the user asked for two of+# one agent and got two of another, with nothing said.+++async def test_an_unclear_cli_name_is_asked_about_rather_than_guessed(+ manager: tuple[BrainManager, FakeBus], registry: Registry, tmp_path: Path+) -> None:+ mgr, _bus = manager+ await _open(registry, tmp_path, 1)++ reply = await mgr._run_agentic_ide_spawn_fast_path("open two Klohd terminals")++ assert reply is not None+ assert "Klohd" in reply+ assert "Claude Code" in reply+ # Nothing was opened on a guess.+ assert registry.session is not None+ assert len(registry.session.terminals) == 1+++async def test_naming_the_cli_in_the_answer_opens_the_whole_fleet(+ manager: tuple[BrainManager, FakeBus], registry: Registry, tmp_path: Path+) -> None:+ mgr, _bus = manager+ await _open(registry, tmp_path, 1, agent="claude")++ await mgr._run_agentic_ide_spawn_fast_path("open two Klohd terminals and one Codex")+ reply = await mgr._run_agentic_ide_spawn_fast_path("Codex")++ assert reply is not None+ assert registry.session is not None+ # One pane was already open; the answered fleet adds three.+ agents = [t.agent for t in registry.session.terminals]+ assert len(agents) == 4+ assert agents.count("codex") == 3, (+ "the answer has to fill in the group that was unclear AND keep the one "+ "that was not"+ )+++async def test_yes_answers_a_question_that_offered_one_name(+ manager: tuple[BrainManager, FakeBus], registry: Registry, tmp_path: Path+) -> None:+ mgr, _bus = manager+ await _open(registry, tmp_path, 1)++ asked = await mgr._run_agentic_ide_spawn_fast_path("open two Klaudi terminals")+ assert asked is not None and "Claude Code" in asked++ await mgr._run_agentic_ide_spawn_fast_path("yes")++ assert registry.session is not None+ assert len(registry.session.terminals) == 3+++async def test_the_question_is_spent_when_the_user_moves_on(+ manager: tuple[BrainManager, FakeBus], registry: Registry, tmp_path: Path+) -> None:+ """A forgotten question must never open panes during a later turn."""+ mgr, _bus = manager+ await _open(registry, tmp_path, 1)++ await mgr._run_agentic_ide_spawn_fast_path("open two Klohd terminals")+ moved_on = await mgr._run_agentic_ide_spawn_fast_path(+ "actually never mind, what does the wake word do again"+ )++ assert moved_on is None+ assert registry.session is not None+ assert len(registry.session.terminals) == 1+ # And the answer is gone with it: a "Codex" now is a fresh turn, not the+ # missing half of a question nobody is holding any more.+ assert getattr(mgr, "_pending_cli_choice", None) is None+++async def test_a_clearly_named_cli_never_asks(+ manager: tuple[BrainManager, FakeBus], registry: Registry, tmp_path: Path+) -> None:+ """The question must not become the new nagging (clarify mandate)."""+ mgr, _bus = manager+ await _open(registry, tmp_path, 1)++ reply = await mgr._run_agentic_ide_spawn_fast_path(+ "open two Codex terminals and one Claude Code terminal"+ )++ assert reply is not None+ assert "did you mean" not in reply.lower()+ assert registry.session is not None+ assert len(registry.session.terminals) == 4