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(computers): never set up a moved folder in the server's home folder
rubenluetke10-beep0f80d8312305
diff --git a/jarvis/agentic_ide/remote.py b/jarvis/agentic_ide/remote.pyindex 4293edfb12..f1d393d403 100644--- a/jarvis/agentic_ide/remote.py+++ b/jarvis/agentic_ide/remote.py@@ -304,10 +304,22 @@ def remote_folder_for(home: str, local_folder: Path) -> str:# ---------------------------------------------------------------------------+# Two separate commands, never `mkdir -p "$DEST" && cd "$DEST"`: `set -e` does+# not stop on a failure inside an && list, so a mkdir that failed left the+# script running in the server's home folder — where it ran `git init` and a+# forced checkout. On a computer that was this very PC, that home-folder repo+# made every git tool treat the whole user profile as one project (a Codex+# snapshot then ran `git add -A` over it for minutes and starved the machine).+# The home check is the second line of defence: the copy has its own folder._APPLY = r"""set -eDEST={dest}; BUNDLE={bundle}; REF={ref}; BASE={base}; BRANCH={branch}; SNAP={snap}-mkdir -p "$DEST" && cd "$DEST"+mkdir -p "$DEST"+cd "$DEST"+if [ "$(pwd -P)" = "$(cd "$HOME" && pwd -P)" ]; then+ echo "refusing to set up the code in the home folder itself" >&2+ exit 1+fi[ -d .git ] || git init -qif git rev-parse -q --verify HEAD >/dev/null && [ -n "$(git status --porcelain)" ]; thenexport GIT_INDEX_FILE="$(mktemp)"; git read-tree HEAD; git add -A; t=$(git write-tree)diff --git a/tests/unit/agentic_ide/test_remote_apply_script.py b/tests/unit/agentic_ide/test_remote_apply_script.pynew file mode 100644index 0000000000..0785467e50--- /dev/null+++ b/tests/unit/agentic_ide/test_remote_apply_script.py@@ -0,0 +1,106 @@+"""The server-side script that sets up a copied folder never runs in the home folder.++`_APPLY` runs on the connected computer, in a shell that starts in the home+folder. It used to open with `mkdir -p "$DEST" && cd "$DEST"`, and `set -e`+does not stop on a failure inside an && list — so a mkdir that failed left the+script in the home folder, where it ran `git init` and a forced checkout. On a+"remote" computer that was the user's own PC, that stray repository made every+git tool treat the whole user profile as one project.++These run the real script in bash (Git Bash on Windows) against a throwaway+home folder; nothing reaches a server.+"""++from __future__ import annotations++import os+import shlex+import shutil+import subprocess+from pathlib import Path++import pytest++from jarvis.agentic_ide.remote import _APPLY+from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS+++def _bash() -> str | None:+ """A bash that understands this OS's paths — Git Bash on Windows, never WSL's."""+ if os.name != "nt":+ return shutil.which("bash")+ git = shutil.which("git")+ if git is None:+ return None+ for root in Path(git).resolve().parents[1:3]:+ candidate = root / "bin" / "bash.exe"+ if candidate.is_file():+ return str(candidate)+ return None+++BASH = _bash()++pytestmark = pytest.mark.skipif(+ BASH is None or shutil.which("git") is None, reason="needs bash and git"+)+++def home(tmp_path: Path) -> Path:+ folder = tmp_path / "home"+ folder.mkdir()+ return folder.resolve()+++def _run_apply(home: Path, dest: str) -> subprocess.CompletedProcess[str]:+ assert BASH is not None+ script = _APPLY.format(+ dest=shlex.quote(dest),+ bundle=shlex.quote((home / "missing.bundle").as_posix()),+ ref=shlex.quote("refs/jarvis/offload/test"),+ base=shlex.quote(""),+ branch=shlex.quote(""),+ snap=shlex.quote("0" * 40),+ )+ return subprocess.run(+ [BASH, "-s"],+ input=script,+ cwd=home, # an SSH session starts in the home folder+ env={**os.environ, "HOME": str(home), "GIT_CEILING_DIRECTORIES": str(home.parent)},+ capture_output=True,+ text=True,+ encoding="utf-8",+ errors="replace",+ timeout=120,+ check=False,+ creationflags=NO_WINDOW_CREATIONFLAGS,+ )+++def test_a_folder_that_cannot_be_created_stops_the_script(home: Path) -> None:+ blocker = home / "blocker"+ blocker.write_text("a file where the folder should go", encoding="utf-8")++ result = _run_apply(home, (blocker / "workspace").as_posix())++ assert result.returncode != 0+ assert not (home / ".git").exists(), "the script set up a repository in the home folder"+++def test_the_home_folder_itself_is_refused(home: Path) -> None:+ result = _run_apply(home, home.as_posix())++ assert result.returncode != 0+ assert "home folder" in result.stderr+ assert not (home / ".git").exists()+++def test_a_normal_folder_still_gets_its_repository(home: Path) -> None:+ dest = home / "jarvis-workspaces" / "app-abc123"++ # Fails later on the missing bundle; what matters is where it got to.+ _run_apply(home, dest.as_posix())++ assert (dest / ".git").is_dir()+ assert not (home / ".git").exists()