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.

2.0 KB
Raw Blame
"""CONNECTED CLIS prompt section renderer (design 2026-06-10 §5.3)."""
from tests.unit.clis._fakes import FakeCliRegistry, FakeTool, make_spec


def test_renders_connected_cli_with_description_and_examples():
    from dodaios.clis.prompt_section import render_connected_clis_section

    fake = FakeCliRegistry({"gh": make_spec("gh")}, active=[FakeTool("cli_gh")])
    section = render_connected_clis_section(fake)
    assert "CONNECTED CLIS" in section
    assert "cli_gh" in section
    assert "gh test capability." in section  # decl description preferred
    assert "`gh list`" in section  # example commands rendered


def test_empty_when_nothing_connected():
    from dodaios.clis.prompt_section import render_connected_clis_section

    fake = FakeCliRegistry({"gh": make_spec("gh")}, active=[])
    assert render_connected_clis_section(fake) == ""


def test_falls_back_to_spec_description_without_capabilities():
    from dataclasses import replace

    from dodaios.clis.prompt_section import render_connected_clis_section

    spec = replace(make_spec("gh"), capabilities=())
    fake = FakeCliRegistry({"gh": spec}, active=[FakeTool("cli_gh")])
    assert "gh CLI." in render_connected_clis_section(fake)


def test_defensive_on_broken_registry():
    from dodaios.clis.prompt_section import render_connected_clis_section

    class _Broken:
        def active_tools(self):
            raise RuntimeError("boom")

    assert render_connected_clis_section(_Broken()) == ""


def test_section_prefers_cli_over_plugin():
    from dodaios.clis.prompt_section import render_connected_clis_section

    fake = FakeCliRegistry({"gh": make_spec("gh")}, active=[FakeTool("cli_gh")])
    out = render_connected_clis_section(fake)
    assert "plugin" in out.lower()  # explicit CLI-over-plugin wording


def test_section_tells_model_to_self_discover_with_help():
    from dodaios.clis.prompt_section import render_connected_clis_section

    fake = FakeCliRegistry({"gh": make_spec("gh")}, active=[FakeTool("cli_gh")])
    out = render_connected_clis_section(fake)
    assert "--help" in out