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.

1.8 KB
Raw Blame
"""Render the CONNECTED CLIS system-prompt section.

Design §5.3 (docs/superpowers/specs/2026-06-10-cli-first-class-capabilities-
design.md): only connected/usable CLIs appear; the section is "" when none
are. Mirrors render_available_skills_section (dodaios/skills/prompt_injection.py):
static per connect/disconnect, cheap to render, defensive against any registry
fault — the system-prompt build must never crash.
"""

from __future__ import annotations

import logging
from typing import Any

from dodaios.clis.tool import TOOL_NAME_PREFIX

log = logging.getLogger(__name__)

_HEADER = "CONNECTED CLIS (preferred over a plugin for the same service):\n"
_FOOTER = "\nRun `<cli> --help` when unsure of a command; prefer --json output."


def render_connected_clis_section(cli_registry: Any) -> str:
    try:
        active = {t.name for t in cli_registry.active_tools()}
        if not active:
            return ""
        lines: list[str] = []
        for spec in cli_registry.catalog().all().values():
            tool_name = f"{TOOL_NAME_PREFIX}{spec.name}"
            if tool_name not in active:
                continue
            if spec.capabilities:
                summary = " ".join(dict.fromkeys(d.description for d in spec.capabilities))
            else:
                summary = spec.description
            line = f"• {tool_name} — {spec.display_name}: {summary}"
            examples = ", ".join(f"`{e}`" for e in spec.tool_schema_examples[:2])
            if examples:
                line += f" (e.g. {examples})"
            lines.append(line)
        if not lines:
            return ""
        return _HEADER + "\n".join(lines) + _FOOTER
    except Exception:  # noqa: BLE001 — prompt build must never crash
        log.debug("connected-CLIs section render failed", exc_info=True)
        return ""


__all__ = ["render_connected_clis_section"]