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(dictation): recognize spoken bullet commands and format bullet lists
rubenluetke10-beepe35272eb3617
diff --git a/jarvis/dictation/polish_guards.py b/jarvis/dictation/polish_guards.pyindex 48d1d6257e..318c2748aa 100644--- a/jarvis/dictation/polish_guards.py+++ b/jarvis/dictation/polish_guards.py@@ -46,6 +46,7 @@ from __future__ import annotationsimport reimport unicodedata+from collections import Counterfrom collections.abc import Sequencefrom typing import Final@@ -382,6 +383,7 @@ _FORMAT_COMMAND_WORDS: Final[dict[str, frozenset[str]]] = {"quote", "unquote", "quotes", "question", "exclamation", "mark","bullet", "bullets", "paragraph", "newline", "ellipsis","parenthesis", "parentheses", "bracket", "brackets", "slash",+ "next", "point",}),"de": frozenset({ # i18n-allow: German spoken commands (§1 list #3)"punkt", "komma", "doppelpunkt", "semikolon", "strichpunkt", # i18n-allow@@ -615,6 +617,79 @@ def _digit_runs(text: str) -> frozenset[str]:return frozenset(_DIGIT_RUN_RE.findall(_DIGIT_SEPARATOR_RE.sub("", str(text or ""))))+#: A produced list line: "- ", "• ", "* ", "3. ", "3) " at the start of a+#: line. What the discount below accepts as EVIDENCE that a spoken marker+#: command was actually converted rather than merely deleted.+_LIST_LINE_RE = re.compile(r"(?m)^[ \t]*(?:[-•*]|\d{1,3}[.)])\s")++#: A marker command is at most two words ("next point", "nächster Punkt"), # i18n-allow+#: so one produced list line licenses at most this many discounted tokens.+_MAX_MARKER_WORDS_PER_LINE = 2+++def _list_lines(text: str) -> int:+ """How many list-marker lines *text* contains."""+ return len(_LIST_LINE_RE.findall(str(text or "")))+++def _ratio_word_counts(+ raw: str, polished: str, commands: frozenset[str]+) -> tuple[int, int]:+ """The two sides of the word-count band, with formatting commands settled.++ The band compares CONTENT, and a spoken command is not content: converted+ correctly it becomes a mark ("comma" -> ","), so a bullet dictation that+ names the marker before every item HALVES its word count and an+ unadjusted band rejects exactly the answers the prompt asked for. But a+ naive "subtract every command word" discount opens two holes the first+ version of this function shipped with, so what is subtracted is decided+ per occurrence:++ * an occurrence present on BOTH sides is a content homonym (a German+ sentence about the most important "Punkt") — subtracted from both # i18n-allow+ sides, so it cancels instead of shrinking only the denominator and+ pushing an unchanged answer over the growth ceiling;+ * a RAW-only occurrence is a command the model may have converted — but+ the discount has to be EARNED: it is granted only up to+ ``_MAX_MARKER_WORDS_PER_LINE`` tokens per NEW list line in the answer.+ A model that summarised a commanded dictation into plain prose shows no+ list lines, earns no discount, and is caught by ``ratio_shrink``+ exactly as before this function existed;+ * an OUTPUT-only occurrence is a word the model ADDED — never discounted,+ so padding an answer with command vocabulary ("mark mark mark") counts+ as the growth it is.++ Punctuation commands earn no discount from list lines and need none: a+ dictation would have to be nearly half command words before their loss+ trips the shrink floor, and real punctuation-command density sits far+ below that.++ ``total`` and ``hits`` come from two different tokenizers on purpose+ (``count_words`` = ``\\w+``, ``_compare_tokens`` = ``[\\w']+``); the+ mismatch is at most the apostrophes, and both sides share it.++ A side that discounts to zero is returned as zero: the caller's+ ``if raw_words:`` skip then treats a commands-only dictation like an+ empty one, which it is, content-wise.+ """+ raw_total = count_words(raw)+ out_total = count_words(polished)+ if not commands or not raw_total:+ return raw_total, out_total+ raw_hits = Counter(t for t in _compare_tokens(raw) if t in commands)+ out_hits = Counter(t for t in _compare_tokens(polished) if t in commands)+ shared = sum((raw_hits & out_hits).values())+ converted = sum((raw_hits - out_hits).values())+ evidence = (+ max(0, _list_lines(polished) - _list_lines(raw))+ * _MAX_MARKER_WORDS_PER_LINE+ )+ return (+ max(0, raw_total - shared - min(converted, evidence)),+ max(0, out_total - shared),+ )++def _lost_quantity_word(raw: str, out: str, *, language: str) -> bool:"""Whether a spoken QUANTITY vanished without a digit taking its place.@@ -791,8 +866,24 @@ def _polish_drift_reason(if _is_meta_output(raw, polished):return "meta_output"- raw_words = count_words(raw)- out_words = count_words(polished)+ # Detected up front because TWO checks below want the text's own language+ # rather than its label: the command-word discount here and the rare-token+ # lookup further down. The check ORDER is unchanged — a ratio rejection+ # still outranks a language flip on the history row.+ raw_language = detect_text_language(raw)+ out_language = detect_text_language(polished)++ # The band runs on content words: the spoken formatting commands are+ # settled first (see ``_ratio_word_counts``). The table follows the TEXT+ # where the detector has an opinion and the label only as a fallback,+ # exactly like the rare-token lookup below — a mislabelled command-heavy+ # dictation would otherwise earn no discount and be rejected as a shrink,+ # the precise failure this discount exists to prevent.+ commands = _FORMAT_COMMAND_WORDS.get(+ _language_key(raw_language if raw_language != "unknown" else language),+ frozenset(),+ )+ raw_words, out_words = _ratio_word_counts(raw, polished, commands)if raw_words:ratio = out_words / raw_wordsif ratio < max_shrink:@@ -802,8 +893,6 @@ def _polish_drift_reason(# Skipped whenever EITHER side is undecided: the detector only knows# de/en/es, so "unknown" means "no opinion", never "different".- raw_language = detect_text_language(raw)- out_language = detect_text_language(polished)if raw_language != "unknown" and out_language != "unknown":if raw_language != out_language:return "language_flip"@@ -937,8 +1026,18 @@ def translate_drift_reason(if len(translated) > len(raw) * _CROSS_SCRIPT_MAX_CHAR_GROWTH:return "ratio_growth"else:- raw_words = count_words(raw)- out_words = count_words(translated)+ # The same command-word settlement the polish band runs+ # (``_ratio_word_counts``), keyed on the SOURCE language the detector+ # names — the commands were spoken there, and the translated side+ # rarely contains them at all, which makes the settlement effectively+ # a raw-side discount gated on produced list lines. The wide translate+ # band absorbs single-word markers on its own, but a two-word marker+ # ("nächster Punkt") spends two-thirds of a bullet dictation's words # i18n-allow+ # on commands and lands under even this band's floor.+ commands = _FORMAT_COMMAND_WORDS.get(+ _language_key(detect_text_language(raw)), frozenset()+ )+ raw_words, out_words = _ratio_word_counts(raw, translated, commands)if raw_words:ratio = out_words / raw_wordsif ratio < max_shrink:diff --git a/jarvis/dictation/polish_prompt.py b/jarvis/dictation/polish_prompt.pyindex 287a6318b3..76bdf1ccf5 100644--- a/jarvis/dictation/polish_prompt.py+++ b/jarvis/dictation/polish_prompt.py@@ -50,7 +50,14 @@ from typing import Final#: enumeration adverb changes the word order of what follows, and a model not#: expressly allowed to repair that keeps the adverb rather than break the#: sentence.-POLISH_PROMPT_VERSION: Final[int] = 5+#:+#: v6: bullet lists got their own recognition contract. An explicit spoken+#: list-marker command ("bullet point" and its input-language equivalents)+#: always opens a "- " line; uncommanded bullets need an announced or clearly+#: parallel list; and "turning speech into a list never deletes content" is a+#: stated rule. Matched by the guards' ``_FORMAT_COMMAND_WORDS`` table, which+#: licenses the command words to vanish into the marks that replace them.+POLISH_PROMPT_VERSION: Final[int] = 6#: The delimiters that fence the untrusted transcript inside the user message.#: Deliberately ugly and unlikely to be dictated by accident; deliberately@@ -122,9 +129,16 @@ WHAT YOU MAY DO:never remains at the start of a numbered line. Where dropping the ordinalbreaks the word order of the rest of the item, restructure the item so itreads naturally ("first we prepare the offer" -> "1. We prepare the- offer"). When they listed without counting, start each line with "- ".- Every item keeps the speaker's own words; a running sentence that merely- mentions items in passing stays a sentence.+ offer").+- A spoken list-marker command ALWAYS starts a new "- " line: "bullet+ point", "next point", and their equivalents in the input language. The+ command words become the marker itself and never appear in the text.+- Without a command, use "- " bullets only when the speaker plainly+ delivered an uncounted list: they announced one ("we need the following")+ or spoke three or more short items of the same shape in a row. Turning+ speech into a list never deletes content — every word that is not the+ count, the command or the enumeration word itself stays. When you cannot+ tell a list from a flowing sentence, keep the sentence.- Normalize spoken numbers to numerals where a writer would ("seven" -> "7"),but never invent a number that was not spoken.- Remove stray ellipses left by the recognizer at a pause.diff --git a/jarvis/dictation/translate_prompt.py b/jarvis/dictation/translate_prompt.pyindex 478b722626..2fed3bc948 100644--- a/jarvis/dictation/translate_prompt.py+++ b/jarvis/dictation/translate_prompt.py@@ -53,7 +53,11 @@ from jarvis.dictation.polish_prompt import (#: v4: mirrors the polish prompt's v5 — the digit ALWAYS replaces the spoken#: ordinal, and restructuring the remaining item is expressly licensed. Live#: runs split the lines but kept the ordinal word written out.-TRANSLATE_PROMPT_VERSION: Final[int] = 4+#:+#: v5: mirrors the polish prompt's v6 — a spoken list-marker command always+#: opens a "- " line and never survives into the text, and "a list never+#: deletes content" is a stated rule.+TRANSLATE_PROMPT_VERSION: Final[int] = 5#: English names for every code ``[dictation].translate_target`` accepts.#:@@ -153,8 +157,11 @@ CLEAN IT UP AS YOU GO — this is dictated speech, not written prose:one item per line, numbered "1.", "2.", "3." when the speaker counted, "- "bullets when they did not. The digit ALWAYS replaces the spoken ordinal —an ordinal word never remains at the start of a numbered line; restructure- the rest of the item where dropping it requires. A running sentence that- merely mentions items in passing stays a sentence.+ the rest of the item where dropping it requires. A spoken list-marker+ command ("bullet point" and its source-language equivalents) always opens+ a "- " line and never survives into the text. Turning speech into a list+ never deletes content, and a running sentence that merely mentions items+ in passing stays a sentence.- Normalize spoken numbers to numerals where a writer would, but never inventa number that was not spoken.- Drop stray ellipses the recognizer left at a pause.diff --git a/tests/unit/dictation/test_polish_guards.py b/tests/unit/dictation/test_polish_guards.pyindex b13443b070..3e5002e066 100644--- a/tests/unit/dictation/test_polish_guards.py+++ b/tests/unit/dictation/test_polish_guards.py@@ -325,6 +325,83 @@ def test_an_uncounted_enumeration_may_become_a_bulleted_list() -> None:assert verdict(raw, polished, language="de") == ""+def test_a_spoken_bullet_command_becomes_a_bullet_line() -> None:+ """The guaranteed path to a bullet list: the speaker names the marker+ before every item. The command word vanishes into the "- " that replaces+ it — licensed by ``_FORMAT_COMMAND_WORDS`` — and the word count HALVES,+ which the band only survives because commands are counted out of the+ ratio on both sides. Before both fixes this dictation was rejected twice+ over: ``lost_term`` for the vanished command, ``ratio_shrink`` for the+ words it took with it."""+ # The German source below is the content UNDER TEST (§1 list #4).+ raw = "Stichpunkt Milch Stichpunkt Eier Stichpunkt Butter" # i18n-allow+ polished = "- Milch\n- Eier\n- Butter" # i18n-allow+ assert verdict(raw, polished, language="de") == ""+++def test_a_spoken_punctuation_command_becoming_its_mark_passes() -> None:+ """The latent twin of the bullet-command bug, present since v1: the prompt+ has always licensed "comma" -> ",", but the vanished command word was a+ rare token to the guard and the conversion was rejected as ``lost_term``.+ """+ # The German source below is the content UNDER TEST (§1 list #4).+ raw = "wir treffen uns um drei Komma bring bitte die Unterlagen mit" # i18n-allow+ polished = "Wir treffen uns um 3, bring bitte die Unterlagen mit." # i18n-allow+ assert verdict(raw, polished, language="de") == ""+++def test_a_content_homonym_of_a_command_cancels_on_both_sides() -> None:+ """Command words are subtracted from BOTH sides of the ratio. A speaker+ discussing an actual "Punkt" keeps the word in raw and answer alike; were+ only the raw side adjusted, this unchanged-but-punctuated answer would+ score 17/14 = 1.21 and be rejected as ``ratio_growth``."""+ # The German source below is the content UNDER TEST (§1 list #4).+ raw = (+ "der erste Punkt ist gut der zweite Punkt ist besser und der " # i18n-allow+ "dritte Punkt ist am besten" # i18n-allow+ )+ polished = (+ "Der erste Punkt ist gut, der zweite Punkt ist besser, und der " # i18n-allow+ "dritte Punkt ist am besten." # i18n-allow+ )+ assert verdict(raw, polished, language="de") == ""+++def test_a_summariser_earns_no_discount_from_spoken_commands() -> None:+ """The command discount must be EARNED by produced list lines. A model+ that swallowed a commanded dictation into prose shows none, gets the+ undiscounted ratio, and is caught exactly as before the discount existed+ — without this gate, the vanished command words would subsidise the+ vanished content words."""+ # The German source below is the content UNDER TEST (§1 list #4).+ raw = "Stichpunkt Milch Stichpunkt Eier Stichpunkt Butter" # i18n-allow+ polished = "Milch und mehr" # i18n-allow+ assert verdict(raw, polished, language="de") == "ratio_shrink"+++def test_padding_with_command_vocabulary_is_still_growth() -> None:+ """Only occurrences the RAW side also carries are settled. Command+ vocabulary the model ADDED is never discounted, so an answer padded with+ it counts as the growth it is."""+ raw = "please send the report today"+ polished = "Please send the report today mark mark mark mark mark mark."+ assert verdict(raw, polished) == "ratio_growth"+++def test_a_two_word_marker_is_discounted_per_produced_line() -> None:+ """A two-word marker ("next point" and its German twin below) spends TWO+ command words on every produced line, which is why the discount is capped+ per line rather than granted per word — and why the cap is two, not one."""+ # The German source below is the content UNDER TEST (§1 list #4).+ raw = "nächster Punkt Milch nächster Punkt Eier nächster Punkt Butter" # i18n-allow+ polished = "- Milch\n- Eier\n- Butter" # i18n-allow+ assert verdict(raw, polished, language="de") == ""++ raw_en = "we need next point apples next point oranges next point bananas"+ polished_en = "We need:\n- Apples\n- Oranges\n- Bananas"+ assert verdict(raw_en, polished_en) == ""++# --------------------------------------------------------------------------- ## The helpers the guards are built out of# --------------------------------------------------------------------------- #diff --git a/tests/unit/dictation/test_polish_precision.py b/tests/unit/dictation/test_polish_precision.pyindex be6c5b88c6..4a01776bc5 100644--- a/tests/unit/dictation/test_polish_precision.py+++ b/tests/unit/dictation/test_polish_precision.py@@ -265,6 +265,27 @@ def test_sharpening_may_not_become_writing() -> None:)+def test_the_command_settlement_holds_under_the_precision_band() -> None:+ """The precision guard shares the command-word settlement with the+ ordinary one, and here it matters MORE: the rare-token backstop is+ already traded away, so the band is the only thing standing between a+ commanded bullet list and a padded or summarised answer. Four items+ rather than three, because the precision shrink floor (0.45) is looser+ than the polish one and a three-item summary would slip past it."""+ # The German source below is the content UNDER TEST (§1 list #4).+ raw = "Stichpunkt Milch Stichpunkt Eier Stichpunkt Butter Stichpunkt Brot" # i18n-allow+ bullets = "- Milch\n- Eier\n- Butter\n- Brot" # i18n-allow+ assert _precision_verdict(raw, bullets, language="de") == ""+ summary = "Milch und mehr" # i18n-allow+ assert _precision_verdict(raw, summary, language="de") == "ratio_shrink"++ padded = "Please send the report today mark mark mark mark mark mark mark."+ assert (+ _precision_verdict("please send the report today", padded)+ == "ratio_growth"+ )++def test_a_language_with_no_quantity_table_is_a_no_op() -> None:"""~96 of the recognition languages have no table; none of them get a veto."""assert (diff --git a/tests/unit/dictation/test_translate.py b/tests/unit/dictation/test_translate.pyindex 473ef8505a..aa3a115589 100644--- a/tests/unit/dictation/test_translate.py+++ b/tests/unit/dictation/test_translate.py@@ -545,6 +545,47 @@ def test_a_counted_enumeration_may_cross_as_a_numbered_list() -> None:)+def test_a_spoken_bullet_command_crosses_as_a_bullet_line() -> None:+ """A commanded bullet list translated: the command words vanish into the+ "- " markers AND the language changes. The translate band is wide enough+ to absorb the halved word count without the polish guard's command-word+ adjustment, and no rare-token check exists here to mourn the command."""+ # The German source below is the content UNDER TEST (§1 list #4).+ raw = "Stichpunkt Milch Stichpunkt Eier Stichpunkt Butter" # i18n-allow+ translated = "- Milk\n- Eggs\n- Butter"+ assert (+ translate_drift_reason(+ raw,+ translated,+ target_language="en",+ protected=(),+ max_shrink=0.40,+ max_growth=2.50,+ )+ == ""+ )+++def test_a_two_word_marker_crosses_within_the_band() -> None:+ """A two-word marker spends two thirds of a bullet dictation's words on+ commands: without the command settlement this correct answer scores+ 3/9 = 0.33 and even the wide translate band rejects it as a shrink."""+ # The German source below is the content UNDER TEST (§1 list #4).+ raw = "nächster Punkt Milch nächster Punkt Eier nächster Punkt Butter" # i18n-allow+ translated = "- Milk\n- Eggs\n- Butter"+ assert (+ translate_drift_reason(+ raw,+ translated,+ target_language="en",+ protected=(),+ max_shrink=0.40,+ max_growth=2.50,+ )+ == ""+ )++def test_a_model_that_answered_instead_of_translating_is_caught() -> None:assert (translate_drift_reason(