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(cli): start and update the app from any terminal (#368)

Ruben Lütke5c0a02181435
diff --git a/docs/dodaios-cli.md b/docs/dodaios-cli.md
index 6f546e3bde..72fa4c28c5 100644
--- a/docs/dodaios-cli.md
+++ b/docs/dodaios-cli.md
@@ -41,16 +41,60 @@ It runs on Linux, macOS, and Windows (pure-Python: `typer`, `httpx`,
## Install
-The CLI ships with the package, so after the normal install it is on your PATH:
+The one-line installer puts the commands on your PATH on every OS, per user and
+without administrator rights (`dodaios/setup/cli_path.py`):
+
+| OS | Where the commands live | How the terminal finds them |
+| --- | --- | --- |
+| Windows | `<install folder>in\dodaios.exe`, `dodaiosctl.exe` (and the earlier names `jarvis.exe`, `personal-jarvis.exe`, `jarvisctl.exe`) | that folder is added to the per-user `Path` |
+| macOS | symlinks in `~/.local/bin` | one guarded line in `~/.zshrc` (or the profile of your shell) |
+| Linux | symlinks in `~/.local/bin` | one guarded line in `~/.bashrc` (or the profile of your shell) |
+
+Open a new terminal after the install. An unrelated command that already owns a
+name is kept, never overwritten, and `dodaios --uninstall` removes all of it
+again. A plain `pip install -e .` provides the same commands inside that
+environment.
+
+## Start and update the app
+
+`jarvis` and `personal-jarvis` are earlier names of `dodaios` and still work.
```bash
-pip install -e . # provides the `dodaios` and `dodaiosctl` commands
+dodaios # start the desktop app (window + voice + orb)
+dodaios update # install the newest published version
+dodaios update --check # only report whether a newer version exists
+dodaios serve # headless server for a VPS (no window)
dodaios version
```
-Bare `dodaios` (no subcommand) still launches the app/tray as before; `dodaios serve`
-still starts the headless server. Only the control subcommands (`dodaios missions
-…`, `dodaios brain …`, etc.) route into the CLI.
+Typed into an interactive terminal, `dodaios` starts the app in the background
+and hands the prompt back at once; closing the terminal does not close the app.
+If the app is already open, its window comes to the front. `dodaios --foreground`
+keeps the app attached to the terminal with its log, and shortcuts, autostart
+entries and scripts (no terminal) keep the in-process start they always had. On
+a Linux machine without a screen, `dodaios` stays in the foreground and explains
+what is missing.
+
+`dodaios update` is the terminal twin of the in-app **Update** button for an
+install made with the one-line installer. It uses the same release check, the
+same pinned GitHub release tag and the same installer run, and it rolls back to
+the previous version automatically if anything fails. It reports success only
+when the installer confirms it. The app has to be closed first: a running
+desktop app is never quit from the terminal (only a click in the app may do
+that), so `dodaios update` asks you to quit it or click Update in the app
+instead. A background service that keeps routines running is asked to hand back
+on its own. A developer checkout or a `pip install` cannot update itself and
+gets the matching command (`git pull` / `pip install --upgrade`) instead.
+
+| Exit code | Meaning |
+| --- | --- |
+| 0 | updated, or already the newest version |
+| 1 | the check, download or install failed (an install failure is rolled back) |
+| 2 | this copy cannot update itself (developer checkout, pip install, native installer) |
+| 3 | the app is running and has to be closed first |
+
+Only the control subcommands (`dodaios missions …`, `dodaios brain …`, etc.)
+route into the control CLI described below.
## Auth & discovery
diff --git a/docs/os-parity.md b/docs/os-parity.md
index 7ccbf2a374..ddcd0bc989 100644
--- a/docs/os-parity.md
+++ b/docs/os-parity.md
@@ -1,5 +1,34 @@
# OS Feature Parity — macOS / Linux Gap Register
+## Terminal start and update commands (2026-10-03, T3)
+
+`dodaios` (and its earlier names `jarvis` and `personal-jarvis`) starts the
+desktop app from a terminal and `dodaios update` updates a managed install, on
+every OS. The installer links the commands into `~/.local/bin` on macOS and
+Linux (adding one guarded PATH line to the login shell's profile: zsh, bash,
+fish or `~/.profile`) and copies the console-script launchers into
+`<install>in` on Windows, which goes onto the per-user `Path`;
+`.venv\Scripts` itself is never put on `Path` because it would shadow the
+user's own `python`. There is deliberately no `dodaiosapp` or `personaljarvis`
+alias: Windows paths ignore case and the venv already holds the branded
+`DodaiosApp.exe` launcher (`PersonalJarvis.exe` in earlier releases). Typed
+into an interactive terminal, `dodaios` starts the app detached through the
+restart identity (LaunchServices bundle, branded exe, launcher module); a Linux
+session without `DISPLAY` or `WAYLAND_DISPLAY` keeps the foreground start.
+`dodaios update` stages and finalizes the update in child processes so the
+parent never holds a native module the reinstall replaces (Windows), and
+finalizes in its own process group or session so Ctrl+C cannot interrupt the
+installer. It clears an earlier run's result before installing and reports
+success only when the installer wrote one, and the uninstaller rewrites a shell
+profile atomically with its line endings kept. Covered by
+`tests/unit/setup/test_cli_path.py`, `tests/unit/install/test_cli_links.py`,
+`tests/unit/cli/test_app_update.py` and
+`tests/unit/test_bare_dodaios_starts_desktop.py` with fakes for the registry and
+child processes; verified for real on Windows (a copied launcher runs from
+another folder; `update --check` on a developer checkout). Not yet verified: a
+full `dodaios update` of a managed install on any OS, and the macOS/Linux
+symlink and profile paths on a physical host (CI runs them on Linux).
+
## Credential service renamed to `dodaios` (2026-10-19, T3)
New keys are saved under the credential service `dodaios` on every OS (Windows
diff --git a/dodaios/cli/app_update.py b/dodaios/cli/app_update.py
index c14eb63846..1947069576 100644
--- a/dodaios/cli/app_update.py
+++ b/dodaios/cli/app_update.py
@@ -130,6 +130,10 @@ def _run_child(args: list[str], timeout: float | None, detached: bool) -> tuple[
cmd = [sys.executable, "-m", "dodaios.cli.app_update", *args]
env = {**os.environ, "PYTHONIOENCODING": "utf-8", "PYTHONUTF8": "1"}
kwargs: dict[str, Any] = {
+ # ``-m`` puts the working directory first on sys.path. Run from the
+ # tree this process came from, so a `dodaios/` folder in the user's
+ # current directory can never stand in for the installed one.
+ "cwd": str(Path(__file__).resolve().parents[2]),
"stdin": subprocess.DEVNULL,
"stdout": subprocess.PIPE,
"stderr": subprocess.DEVNULL,
@@ -257,6 +261,13 @@ def _read_result(root: Path, file_name: str) -> dict[str, Any]:
return payload if isinstance(payload, dict) else {}
+def _clear_result(root: Path, file_name: str) -> None:
+ try:
+ (root / file_name).unlink(missing_ok=True)
+ except OSError as exc:
+ print(f" (could not clear the previous update result: {exc})", file=sys.stderr)
+
+
def run_update(
*,
check_only: bool = False,
@@ -311,9 +322,11 @@ def run_update(
print(f"Run `{main_command()} update` to install it.")
return 0
- pid = running_app_pid()
+ # The service is found by its own marker, not through the session file: a
+ # live service with a missing or stale session.json would otherwise keep
+ # the venv's native modules open through the whole reinstall.
service = status.get("service_pid")
- if pid is not None and service and pid == service:
+ if service:
print("Stopping the background service for the update...", flush=True)
if not stop_service(int(service)):
print(
@@ -322,8 +335,8 @@ def run_update(
file=sys.stderr,
)
return EXIT_APP_RUNNING
- pid = None
- if pid is not None:
+ pid = running_app_pid()
+ if pid is not None and pid != service:
print(
"Dodaios is running, and it cannot be updated while it is open.\n"
"Either click Update inside the app, or quit it (tray icon -> Quit)\n"
@@ -347,15 +360,17 @@ def run_update(
# release, and an import from this process would read THAT release's files
# - or fail outright if it moved the package.
result_file_name = _result_file_name()
+ # A result left by an earlier run must not speak for this one.
+ _clear_result(root, result_file_name)
with _Ticker(
f"Installing version {version} - this takes a few minutes, keep this window open...",
enabled=interactive,
):
code, _ = run_child([FINALIZE_FLAG, str(root)], None, True)
result = _read_result(root, result_file_name)
- if code == 0 and result.get("ok", True):
+ if code == 0 and result.get("ok") is True:
print(f"Done. Dodaios {version} is installed.")
- print("Start it with: jarvis")
+ print(f"Start it with: {main_command()}")
return 0
if result.get("rolled_back"):
print(
diff --git a/dodaios/setup/cli_path.py b/dodaios/setup/cli_path.py
index e71454e76f..5ea85a9c56 100644
--- a/dodaios/setup/cli_path.py
+++ b/dodaios/setup/cli_path.py
@@ -203,8 +203,11 @@ def add_profile_block(path: Path) -> bool:
def remove_profile_block(path: Path) -> bool:
"""Delete the block :func:`add_profile_block` wrote. False when absent."""
try:
- lines = path.read_text(encoding="utf-8").splitlines(keepends=True)
- except (FileNotFoundError, UnicodeDecodeError): # An absent or unreadable profile cannot contain a removable managed block.
+ # newline="" keeps CRLF profiles CRLF: only our two lines change.
+ with path.open(encoding="utf-8", newline="") as handle:
+ lines = handle.read().splitlines(keepends=True)
+ except (FileNotFoundError, UnicodeDecodeError):
+ # An absent or unreadable profile cannot contain a removable managed block.
return False
kept: list[str] = []
skip_next = False
@@ -222,7 +225,16 @@ def remove_profile_block(path: Path) -> bool:
continue
kept.append(line)
if removed:
- path.write_text("".join(kept), encoding="utf-8", newline="")
+ # Write beside, then swap: a crash mid-write must never leave the
+ # user's shell profile truncated.
+ temp = path.with_name(path.name + ".dodaios.tmp")
+ with temp.open("w", encoding="utf-8", newline="") as handle:
+ handle.write("".join(kept))
+ try:
+ shutil.copymode(path, temp)
+ except OSError: # noqa: S110 - mode copy is cosmetic; content is what matters
+ pass
+ os.replace(temp, path)
return removed
@@ -242,7 +254,8 @@ class UserPathStore:
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Environment") as key:
try:
value, kind = winreg.QueryValueEx(key, "Path")
- except FileNotFoundError: # A missing user PATH value is the empty starting configuration.
+ except FileNotFoundError:
+ # No per-user Path value yet: it is created with the bin folder.
return "", None
return str(value), int(kind)
@@ -313,15 +326,21 @@ def _copy_launcher(source: Path, target: Path) -> bool:
try:
if target.read_bytes() == data:
return False
- except FileNotFoundError: # No existing launcher means there is nothing to preserve before creation.
+ except FileNotFoundError: # no launcher copy yet: it is written below
pass
try:
target.write_bytes(data)
- except PermissionError: # A running Windows launcher is renamed before its replacement is written.
+ except PermissionError:
stale = target.with_name(target.name + _STALE_SUFFIX)
stale.unlink(missing_ok=True)
target.rename(stale)
- target.write_bytes(data)
+ try:
+ target.write_bytes(data)
+ except OSError:
+ # Put the working launcher back rather than leave no command.
+ target.unlink(missing_ok=True)
+ stale.rename(target)
+ raise
return True
@@ -336,7 +355,7 @@ def _sweep_stale_launchers(directory: Path) -> None:
def _link_points_into(link: Path, root: Path) -> bool:
try:
return link.is_symlink() and root.resolve() in link.resolve().parents
- except OSError: # Unverifiable links are treated as foreign and preserved.
+ except OSError: # an unreadable link is treated as not ours, so it is kept
return False
diff --git a/tests/unit/cli/test_app_update.py b/tests/unit/cli/test_app_update.py
index f20c4e4eeb..5e9b5c561d 100644
--- a/tests/unit/cli/test_app_update.py
+++ b/tests/unit/cli/test_app_update.py
@@ -215,6 +215,37 @@ def test_jarvis_main_routes_update(monkeypatch):
assert seen == [True]
+def test_service_without_a_session_file_is_still_stopped(tmp_path):
+ """A live service with a missing session.json must not stay up through
+ the reinstall, where it would hold the venv's native modules open."""
+ stopped: list[int] = []
+ children = FakeChildren(
+ status=_status(service_pid=777),
+ stage={"ok": True, "root": str(tmp_path), "version": "2.9.0"},
+ on_finalize=lambda root: _write_result(root, ok=True, rolled_back=False),
+ )
+ rc = _run(
+ children,
+ running_app_pid=lambda: None,
+ stop_service=lambda pid: stopped.append(pid) or True,
+ )
+ assert rc == 0
+ assert stopped == [777]
+
+
+def test_stale_result_from_an_earlier_run_is_not_reported(tmp_path, capsys):
+ _write_result(tmp_path, ok=False, rolled_back=True)
+ children = FakeChildren(
+ status=_status(),
+ stage={"ok": True, "root": str(tmp_path), "version": "2.9.0"},
+ finalize_rc=1, # the finalize child died without writing a result
+ )
+ assert _run(children) == EXIT_FAILED
+ err = capsys.readouterr().err
+ assert "went back to" not in err
+ assert "could not be restored automatically" in err
+
+
# --------------------------------------------------------------------------- #
# Nothing is imported from the package once the install step has run
# --------------------------------------------------------------------------- #
diff --git a/tests/unit/setup/test_cli_path.py b/tests/unit/setup/test_cli_path.py
index a23167dcb3..2815938e9d 100644
--- a/tests/unit/setup/test_cli_path.py
+++ b/tests/unit/setup/test_cli_path.py
@@ -249,6 +249,16 @@ def test_no_command_collides_with_the_branded_windows_launcher():
assert branded not in {command.casefold() for command in COMMAND_NAMES}
+def test_profile_removal_keeps_crlf_line_endings(tmp_path):
+ profile = tmp_path / ".profile"
+ profile.write_bytes(b"export A=1\r\nexport B=2\r\n")
+ add_profile_block(profile)
+ assert remove_profile_block(profile) is True
+ assert profile.read_bytes().startswith(b"export A=1\r\nexport B=2\r\n")
+ assert PROFILE_MARKER.encode() not in profile.read_bytes()
+ assert not list(tmp_path.glob("*.tmp"))
+
+
# ------------------------------------------- installs made before a command existed
#: What an earlier version wrote into a profile, byte for byte. The marker line
#: names the commands of that time; it is how the block is found again.