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
fix(clis): augment the GUI PATH with well-known install dirs so installed CLIs are detected
Ruben Lütkea8d44755c078
diff --git a/jarvis/__main__.py b/jarvis/__main__.pyindex 3b2fc3f12b..17099a8fc7 100644--- a/jarvis/__main__.py+++ b/jarvis/__main__.py@@ -482,6 +482,13 @@ def _run_control(argv: list[str]) -> int:def main(argv: list[str] | None = None) -> int:+ # GUI launches (Finder/Dock on macOS, tray relaunch on Windows) start with+ # a minimal PATH that misses Homebrew/npm/winget install dirs — augment it+ # before ANY CLI probe or subprocess spawn runs (stat-only, AP-26-safe).+ from jarvis.core.path_augment import ensure_cli_paths++ ensure_cli_paths()+raw = list(sys.argv[1:] if argv is None else argv)# Unified entry point: `jarvis <group> ...` (or a control-global option like# `--json`) drives the control CLI; bare `jarvis`, `jarvis serve`, and everydiff --git a/jarvis/core/path_augment.py b/jarvis/core/path_augment.pynew file mode 100644index 0000000000..19544a038b--- /dev/null+++ b/jarvis/core/path_augment.py@@ -0,0 +1,117 @@+"""Augment the process PATH with well-known CLI install locations.++GUI-launched processes do not inherit the user's shell PATH: on macOS an app+started from Finder/Dock/launchd gets the minimal ``/usr/bin:/bin:/usr/sbin:+/sbin`` (no Homebrew, no npm-global, no ``~/.local/bin``), and on Windows a+winget install appends its ``WinGet\\Links`` shim dir to the *registry* PATH,+which already-running processes never see. Every ``shutil.which``-based CLI+probe (claude / codex / gemini / node / npm, the CLI-tools catalog prober,+worker spawns) then reports a perfectly-installed binary as "not installed" —+the 2026-07-18 Mac-test-machine symptom: Claude Code installed via the shell,+the desktop app insisting it is missing.++``ensure_cli_paths()`` appends the well-known, actually-existing install dirs+to ``os.environ["PATH"]``. Existing entries keep priority — only *missing*+dirs are appended, so a user-managed PATH always wins and the call is+idempotent. Pure ``stat()`` probes, no subprocess: boot-budget-safe (AP-26).++Cross-platform per CLOUD.md Rule #1: the candidate list covers macOS+(Intel + Apple Silicon Homebrew), Linux (incl. headless), and Windows; a dir+that does not exist on this host is simply skipped.+"""+from __future__ import annotations++import glob+import logging+import os+import sys+from pathlib import Path++log = logging.getLogger(__name__)+++def _posix_candidates() -> list[str]:+ home = Path.home()+ dirs: list[str] = [+ # Homebrew (Intel Macs + Linuxbrew default) and the npm default prefix.+ "/usr/local/bin",+ # Homebrew on Apple Silicon.+ "/opt/homebrew/bin",+ # MacPorts.+ "/opt/local/bin",+ # Native installers (Claude Code, pipx, uv) and the XDG user bin dir.+ str(home / ".local" / "bin"),+ # Claude Code's npm-local migration target (`claude install`).+ str(home / ".claude" / "local"),+ # A user-configured npm prefix (`npm config set prefix ~/.npm-global`).+ str(home / ".npm-global" / "bin"),+ # Volta pins a single stable shim dir.+ str(home / ".volta" / "bin"),+ ]+ if sys.platform.startswith("linux"):+ dirs.append("/snap/bin")+ # nvm/fnm keep per-node-version bin dirs; a GUI process sees none of them+ # because the shims live in shell init files. Newest-first is best-effort+ # (lexicographic, same trade-off as jarvis.google_cli.resolver) — for a+ # global CLI install ANY hit beats "not installed".+ for pattern in (+ str(home / ".nvm" / "versions" / "node" / "*" / "bin"),+ str(+ home / ".local" / "share" / "fnm" / "node-versions" / "*"+ / "installation" / "bin"+ ),+ ):+ dirs.extend(sorted(glob.glob(pattern), reverse=True))+ return dirs+++def _windows_candidates() -> list[str]:+ dirs: list[str] = []+ local = os.environ.get("LOCALAPPDATA")+ if local:+ # winget's shim dir lands on the *registry* PATH only — a running+ # process (and every subprocess it spawns) misses fresh installs.+ dirs.append(os.path.join(local, "Microsoft", "WinGet", "Links"))+ appdata = os.environ.get("APPDATA")+ if appdata:+ dirs.append(os.path.join(appdata, "npm"))+ return dirs+++def candidate_dirs() -> list[str]:+ """The platform's well-known CLI install dirs (existing or not)."""+ return _windows_candidates() if sys.platform == "win32" else _posix_candidates()+++def ensure_cli_paths() -> list[str]:+ """Append missing well-known CLI dirs to ``PATH``; return what was added.++ Idempotent: dirs already on PATH (case-normalized) are never re-added, so+ repeated calls — and a PATH the user already curated — are both safe.+ """+ current = os.environ.get("PATH", "")+ seen = {+ os.path.normcase(os.path.normpath(p))+ for p in current.split(os.pathsep)+ if p+ }+ added: list[str] = []+ for cand in candidate_dirs():+ try:+ if not os.path.isdir(cand):+ continue+ except OSError:+ continue+ key = os.path.normcase(os.path.normpath(cand))+ if key in seen:+ continue+ seen.add(key)+ added.append(cand)+ if added:+ joined = os.pathsep.join(added)+ os.environ["PATH"] = f"{current}{os.pathsep}{joined}" if current else joined+ log.info("PATH augmented with %d CLI install dir(s): %s", len(added), added)+ return added+++__all__ = ["candidate_dirs", "ensure_cli_paths"]diff --git a/jarvis/ui/web/launcher.py b/jarvis/ui/web/launcher.pyindex c74dbc120d..8a107cdfbe 100644--- a/jarvis/ui/web/launcher.py+++ b/jarvis/ui/web/launcher.py@@ -1022,6 +1022,13 @@ def main(argv: list[str] | None = None) -> int:print(f"[BOOT_PROFILE] m_{_name}={(_now - _m_last) * 1000.0:.1f}", flush=True)_m_last = _now+ # GUI/desktop launches carry a minimal PATH (macOS launchd, Windows tray+ # relaunch) — append the well-known CLI install dirs before any provider+ # probe or worker spawn resolves binaries (stat-only, AP-26-safe).+ from jarvis.core.path_augment import ensure_cli_paths++ ensure_cli_paths()+_raw_argv = argv if argv is not None else sys.argv[1:]args = _parse_args(_raw_argv)diff --git a/tests/unit/core/test_path_augment.py b/tests/unit/core/test_path_augment.pynew file mode 100644index 0000000000..d0552da3d1--- /dev/null+++ b/tests/unit/core/test_path_augment.py@@ -0,0 +1,80 @@+"""Tests for jarvis.core.path_augment — the GUI-PATH augmentation.++The bug class under guard: a GUI-launched process (macOS launchd, Windows tray+relaunch) starts with a minimal PATH, so every ``shutil.which``-based CLI probe+reports an installed claude/codex/gemini as missing. ``ensure_cli_paths`` must+append existing well-known install dirs — and ONLY missing ones, keeping the+user's PATH order authoritative.+"""+from __future__ import annotations++import os+import sys++import pytest++from jarvis.core import path_augment+++def fake_install_dir(tmp_path, monkeypatch):+ """A pretend CLI install dir + a candidate list pinned to it."""+ cli_dir = tmp_path / "cli-bin"+ cli_dir.mkdir()+ missing = tmp_path / "does-not-exist"+ monkeypatch.setattr(+ path_augment, "candidate_dirs", lambda: [str(cli_dir), str(missing)]+ )+ return cli_dir+++def test_appends_existing_dir_and_skips_missing(fake_install_dir, monkeypatch):+ monkeypatch.setenv("PATH", "/usr/bin")+ added = path_augment.ensure_cli_paths()+ assert added == [str(fake_install_dir)]+ parts = os.environ["PATH"].split(os.pathsep)+ # Existing entries keep priority — the new dir is appended, never prepended.+ assert parts[0] == "/usr/bin"+ assert str(fake_install_dir) in parts+++def test_idempotent_second_call_adds_nothing(fake_install_dir, monkeypatch):+ monkeypatch.setenv("PATH", "/usr/bin")+ assert path_augment.ensure_cli_paths()+ before = os.environ["PATH"]+ assert path_augment.ensure_cli_paths() == []+ assert os.environ["PATH"] == before+++def test_dir_already_on_path_is_not_duplicated(fake_install_dir, monkeypatch):+ monkeypatch.setenv("PATH", str(fake_install_dir))+ assert path_augment.ensure_cli_paths() == []+ assert os.environ["PATH"] == str(fake_install_dir)+++def test_empty_path_still_works(fake_install_dir, monkeypatch):+ monkeypatch.setenv("PATH", "")+ added = path_augment.ensure_cli_paths()+ assert added == [str(fake_install_dir)]+ assert os.environ["PATH"] == str(fake_install_dir)+++def test_candidates_are_platform_appropriate():+ dirs = path_augment.candidate_dirs()+ assert dirs, "candidate list must never be empty on a supported platform"+ if sys.platform == "win32":+ assert any("WinGet" in d for d in dirs)+ assert any(d.endswith("npm") for d in dirs)+ else:+ assert "/usr/local/bin" in dirs+ assert "/opt/homebrew/bin" in dirs # Apple-Silicon Homebrew+ assert any(d.endswith(os.path.join(".local", "bin")) for d in dirs)++[email protected](sys.platform == "win32", reason="POSIX candidate shape")+def test_posix_candidates_cover_the_mac_report(monkeypatch):+ """The 2026-07-18 Mac symptom: claude installed via npm/native installer,+ app blind to it. The curated list must cover both install families."""+ dirs = path_augment.candidate_dirs()+ assert any(d.endswith(os.path.join(".claude", "local")) for d in dirs)+ assert any(d.endswith(os.path.join(".npm-global", "bin")) for d in dirs)