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(ide): add a custom terminal command from the add-agent dialog

rubenluetke10-beepa891ad22ca63
diff --git a/jarvis/agentic_ide/intent.py b/jarvis/agentic_ide/intent.py
index 119680e0b4..02ee7943b7 100644
--- a/jarvis/agentic_ide/intent.py
+++ b/jarvis/agentic_ide/intent.py
@@ -1370,6 +1370,11 @@ def _agent_alternation() -> str:
return "|".join(sorted(parts, key=len, reverse=True))
+#: The patterns below are built from the LIVE registry, which changes while the
+#: app runs: a CLI the user adds in the workspace dialog has to be openable by
+#: name ("open five Cursor terminals") in the same session, not after a
+#: restart. :func:`refresh_agent_patterns` rebuilds them; the registry calls it
+#: whenever its entries change.
_AGENT_ALTERNATION = _agent_alternation()
_AGENT_RE = re.compile(rf"\b(?P<agent>{_AGENT_ALTERNATION})\b", re.IGNORECASE)
@@ -1581,12 +1586,14 @@ def _spoken_count(text: str) -> int:
#: "three terminals of Codex" as often as "three Codex terminals") plus the
#: usual qualifiers. Bounded at two words so the count and the agent cannot
#: drift into different clauses of the sentence.
-_COUNT_AGENT_RE = re.compile(
+_COUNT_AGENT_PREFIX = (
r"\b(?P<count>\d{1,3}|[a-zäöüñ]+)\s+" # i18n-allow: input vocab
r"(?:(?:neue|weitere|zus[aä]tzliche|more|new|extra|" # i18n-allow: input vocab
r"additional|de|del|"
r"otros|otras|m[aá]s|terminals?|terminales|panes?|tabs?)\s+){0,2}"
- rf"(?P<agent>{_AGENT_ALTERNATION})\b",
+)
+_COUNT_AGENT_RE = re.compile(
+ rf"{_COUNT_AGENT_PREFIX}(?P<agent>{_AGENT_ALTERNATION})\b",
re.IGNORECASE,
)
@@ -1637,6 +1644,34 @@ _ARTICLE_SIZES_RE = re.compile(
)
+def _compile_agent_patterns(alternation: str) -> None:
+ """Rebind every module pattern that spells out the registered CLI names."""
+ global _AGENT_ALTERNATION, _AGENT_RE, _COUNT_AGENT_RE, _ARTICLE_SIZES_RE
+ _AGENT_ALTERNATION = alternation
+ _AGENT_RE = re.compile(rf"\b(?P<agent>{alternation})\b", re.IGNORECASE)
+ _COUNT_AGENT_RE = re.compile(
+ rf"{_COUNT_AGENT_PREFIX}(?P<agent>{alternation})\b",
+ re.IGNORECASE,
+ )
+ _ARTICLE_SIZES_RE = re.compile(
+ rf"\s*(?:[^\W\d_]+\s+){{0,{_ARTICLE_FILLER_WORDS}}}"
+ rf"(?:{_PANE_NOUN_RE.pattern}|{_AGENT_RE.pattern})",
+ re.IGNORECASE,
+ )
+
+
+def refresh_agent_patterns() -> None:
+ """Re-read the registry's spoken names into this parser's patterns.
+
+ Called by :mod:`jarvis.workspace.agents` whenever an entry is added,
+ edited or removed. Cheap when nothing changed — the alternation is
+ compared before anything is recompiled.
+ """
+ alternation = _agent_alternation()
+ if alternation != _AGENT_ALTERNATION:
+ _compile_agent_patterns(alternation)
+
+
def _article_sizes_something(text: str, end: int) -> bool:
"""Whether the article ending at ``end`` is sizing panes rather than prose."""
return _ARTICLE_SIZES_RE.match(text, end) is not None
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
index 8ee7a7103a..5f84b29540 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
@@ -162,6 +162,21 @@ describe("Agentic IDE project flow", () => {
await waitFor(() => expect(api.addTerminal).toHaveBeenCalledWith({ workspace_id: "w1", agent: "codex", direction: "down" }, { onMessage: expect.any(Function) }));
});
+ it("offers adding a custom command from the add-agent dialog", async () => {
+ const session = { id: "w1", project_id: "p1", folder: "/code/app", name: "App work", created_at: 0,
+ focus_mode: false, project: { name: "App" }, terminals: [] };
+ api.fetchIdeState.mockResolvedValue({ ...emptyState, active: true, active_id: "w1", session });
+ api.fetchIdeProjects.mockResolvedValue({ projects: [project], active_workspace_id: "w1" });
+ render(<AgenticIdeView />);
+ fireEvent.click(await screen.findByRole("button", { name: "Pane add" }));
+ const dialog = screen.getByRole("dialog", { name: "Add coding agent" });
+ fireEvent.click(within(dialog).getByTestId("add-agent-custom-cli"));
+ expect(await screen.findByTestId("custom-cli-dialog")).toBeTruthy();
+ // The picker stays underneath (hidden from assistive tech while the form is
+ // modal), so a saved command can be picked right away.
+ expect(screen.getByRole("dialog", { name: "Add coding agent", hidden: true })).toBeTruthy();
+ });
+
it("splits with a plain terminal even when no coding CLI is installed", async () => {
api.fetchIdeAgents.mockResolvedValue({ agents: [
{ ...agent, installed: false },
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
index 9e21163a07..99629db6d3 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
@@ -1,5 +1,7 @@
import { useCallback, useEffect, useRef, useState } from "react";
-import { FolderPlus, Loader2, X } from "lucide-react";
+import { FolderPlus, Loader2, Plus, X } from "lucide-react";
+import { useT } from "@/i18n";
+import { CustomCliDialog } from "@/components/agentic/CustomCliDialog";
import { ProjectConnectDialog } from "@/components/agentic/ProjectConnectDialog";
import { VoiceBubble, storedVoiceBubbleOpen, storeVoiceBubbleOpen } from "@/components/agentic/VoiceBubble";
import { RetainedWorkspaceGrid } from "@/components/agentic/RetainedWorkspaceGrid";
@@ -98,6 +100,10 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
const [gitOpen, setGitOpen] = useState(false);
const [selected, setSelected] = useState("");
const [agentPicker, setAgentPicker] = useState<{ id: string; name: string } | null>(null);
+ // "Add your own command" from inside the agent picker: the CLI the user wants
+ // is usually missing exactly when they are looking at this list.
+ const [customCliOpen, setCustomCliOpen] = useState(false);
+ const t = useT();
// Where the next agent opens: split off `splitAnchor` (a pane call-sign) in
// `splitDirection`, or — with no anchor — the automatic even grid.
const [splitDirection, setSplitDirection] = useState<PaneSplitDirection>(storedSplitDirection);
@@ -139,7 +145,9 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
}, [session?.id]);
useEffect(() => {
- if (!dialogOpen || projectDialog) return;
+ // The custom-CLI form sits above the agent picker and owns its own focus and
+ // Escape; trapping keys for the picker underneath would steal them.
+ if (!dialogOpen || projectDialog || customCliOpen) return;
const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;
const dialog = document.querySelector<HTMLElement>("[data-ide-dialog]");
if (!dialog) return;
@@ -164,7 +172,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
};
document.addEventListener("keydown", onKeyDown, true);
return () => { document.removeEventListener("keydown", onKeyDown, true); previous?.focus(); };
- }, [dialogOpen, projectDialog, workspaceProject, renameOpen, agentPicker, busy]);
+ }, [dialogOpen, projectDialog, workspaceProject, renameOpen, agentPicker, busy, customCliOpen]);
const refresh = useCallback(async (allowDuringActivation = false) => {
if (((activationRunning.current || gridMutations.current > 0) && !allowDuringActivation)) return;
@@ -642,6 +650,13 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
className="flex min-h-12 items-center gap-3 rounded-lg border border-border px-3 py-2 text-left text-sm font-medium hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
<AgentMark agent={agent.name} label={agent.display_name} logoUrl={agent.logo_url} variant="plain" />{agent.display_name}
</button>)}
+ {/* A command of the user's own, named and marked by them. Once saved
+ it is listed here, in every pane menu, and by its name to voice
+ ("open five Cursor terminals"). */}
+ <button type="button" disabled={busy} data-testid="add-agent-custom-cli" onClick={() => setCustomCliOpen(true)}
+ className="flex min-h-12 items-center gap-3 rounded-lg border border-dashed border-border px-3 py-2 text-left text-sm font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ <Plus className="h-4 w-4" aria-hidden="true" />{t("custom_cli.add_button")}
+ </button>
</div>
{busy && agentComputer && <p role="status" className="mt-3 flex items-center gap-2 text-xs text-muted-foreground">
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden="true" />Copying the folder and starting the agent there. Large folders take a minute.</p>}
@@ -649,6 +664,12 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
</section>
</div>}
+ {/* Outside the picker's backdrop on purpose: a portal still bubbles React
+ events to its parent, and a click in this form must not read as a click
+ on the backdrop that dismisses the picker. */}
+ <CustomCliDialog open={customCliOpen} onOpenChange={setCustomCliOpen}
+ onSaved={() => void fetchIdeAgents(true).then((response) => setAgents(response.agents)).catch((error) => pushToast("error", (error as Error).message))} />
+
{projectDialog && <ProjectConnectDialog onClose={() => setProjectDialog(false)} onConnect={connect} />}
{workspaceProject && <div className="fixed inset-0 z-[80] flex items-center justify-center bg-background/75 p-4 backdrop-blur-sm" role="presentation" onMouseDown={(event) => { if (!busy && event.target === event.currentTarget) setWorkspaceProject(null); }}>
diff --git a/jarvis/workspace/agents.py b/jarvis/workspace/agents.py
index 6b5f406e09..5e8b5ead2f 100644
--- a/jarvis/workspace/agents.py
+++ b/jarvis/workspace/agents.py
@@ -1252,8 +1252,20 @@ def _forget_command_catalog() -> None:
from jarvis.commands.registry import get_registry
get_registry.cache_clear()
- except Exception: # noqa: BLE001 - the catalog is not this module's job
- return
+ except Exception: # noqa: BLE001, S110 - the catalog is not this module's job
+ pass
+ # The spoken-request parser compiles every entry's spoken names into its
+ # patterns. Rebuilt only when it is already loaded: a first import builds
+ # them from the live registry anyway. Looked up in sys.modules rather than
+ # imported, because this runs INSIDE the registry read the parser's own
+ # rebuild performs.
+ intent = sys.modules.get("jarvis.agentic_ide.intent")
+ refresh = getattr(intent, "refresh_agent_patterns", None)
+ if refresh is not None:
+ try:
+ refresh()
+ except Exception as exc: # noqa: BLE001 - a stale parser beats a failed registration
+ log.warning("workspace agents: spoken-name patterns not refreshed: %s", exc)
def list_agents() -> list[WorkspaceAgent]:
diff --git a/tests/unit/workspace/test_custom_clis.py b/tests/unit/workspace/test_custom_clis.py
index c0bcaeadf5..c3dbfb4491 100644
--- a/tests/unit/workspace/test_custom_clis.py
+++ b/tests/unit/workspace/test_custom_clis.py
@@ -415,6 +415,24 @@ def test_a_real_name_is_addressable_by_voice() -> None:
assert registry.spoken_aliases().get("antigravity") == "antigravity"
+def test_a_cli_added_while_running_is_spawnable_by_name() -> None:
+ """"Open five Warpdrive terminals" must work without restarting the app.
+
+ The spawn parser compiles every spoken name into its patterns; an entry
+ added after it was imported used to be invisible to voice until a restart.
+ """
+ from jarvis.agentic_ide import intent
+
+ before = intent.detect_spawn("open five warpdrive terminals")
+ assert before is None or all(group.agent != "warpdrive" for group in before.groups)
+ entry = custom_clis.create_custom_cli("Warpdrive", "warpdrive --tui")
+ registry.refresh_custom_agents()
+
+ request = intent.detect_spawn("open five warpdrive terminals")
+ assert request is not None
+ assert [(group.count, group.agent) for group in request.groups] == [(5, entry.id)]
+
+
def test_a_custom_name_is_reserved_against_pane_call_signs() -> None:
"""Saying "Antigravity" must not be a coin flip between a pane and a CLI."""
custom_clis.create_custom_cli("Antigravity", "agy")