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.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-11 11:22)

Ruben Lütke1145257fd65a
diff --git a/install/install.ps1 b/install/install.ps1
index 2fe973d618..828fe32f14 100644
--- a/install/install.ps1
+++ b/install/install.ps1
@@ -111,7 +111,12 @@ function Test-Tool {
function Test-PythonCandidate {
param([string]$Exe)
try {
- $out = & $Exe -c 'import sys; print("%d.%d.%d" % sys.version_info[:3])' 2>&1
+ # Keep the Python snippet quote-free. Windows PowerShell 5's legacy
+ # native-argument marshaller can strip nested quote characters even
+ # when the PowerShell string itself is correctly quoted.
+ $probe = 'import sys; print(sys.version_info.major, sys.version_info.minor,' +
+ 'sys.version_info.micro, sep=chr(46))'
+ $out = & $Exe -c $probe 2>&1
if ($LASTEXITCODE -ne 0) { return $null }
$version = [string]($out | Select-Object -First 1)
if ($version -notmatch '^(\d+)\.(\d+)\.(\d+)$') { return $null }
@@ -212,6 +217,19 @@ function Get-MissingPrerequisiteLabels {
return $missing
}
+function Test-InstallPromptAvailable {
+ if (-not [Environment]::UserInteractive) { return $false }
+ try {
+ # `irm ... | iex` is a PowerShell object pipeline, not redirected
+ # console input, so it remains prompt-capable. CI/stdin pipelines do
+ # not, and must opt in explicitly with JARVIS_INSTALL_PREREQS=auto.
+ return (-not [Console]::IsInputRedirected)
+ } catch {
+ # Hosts such as PowerShell ISE have no console but provide Read-Host.
+ return $true
+ }
+}
+
function Request-PrerequisiteConsent {
param([string[]]$Missing)
switch ($PrerequisiteMode) {
@@ -227,7 +245,7 @@ function Request-PrerequisiteConsent {
}
}
- if (-not [Environment]::UserInteractive) {
+ if (-not (Test-InstallPromptAvailable)) {
Write-Note 'This shell cannot ask for consent. Re-run interactively or set JARVIS_INSTALL_PREREQS=auto.'
return $false
}
@@ -340,7 +358,7 @@ function Ensure-Prerequisites {
while (-not $state.Ready) {
Write-Err 'The required commands are still unavailable in this terminal.'
Write-ManualPrerequisiteHelp $state
- if ($PrerequisiteMode -eq 'auto' -or -not [Environment]::UserInteractive) {
+ if ($PrerequisiteMode -eq 'auto' -or -not (Test-InstallPromptAvailable)) {
return $null
}
try {
diff --git a/install/install.sh b/install/install.sh
index d13e39bc65..fb8afb320b 100755
--- a/install/install.sh
+++ b/install/install.sh
@@ -152,16 +152,30 @@ find_python() {
# This block stays shell-native because Python may not exist yet. Tests extract
# it directly and exercise the retry/continuation state machine with fakes.
git_available() {
- _git_path=$(command -v git 2>/dev/null) || return 1
- # macOS ships a /usr/bin/git launcher even before the Command Line Tools
- # exist. Calling that launcher may open an unrelated system dialog, so
- # check the toolchain receipt before treating the stub as a real Git.
- if [ "$(uname -s 2>/dev/null || true)" = 'Darwin' ] &&
- [ "$_git_path" = '/usr/bin/git' ] && command -v xcode-select >/dev/null 2>&1 &&
- ! xcode-select -p >/dev/null 2>&1; then
- return 1
- fi
- "$_git_path" --version >/dev/null 2>&1
+ _git_candidates=()
+ _git_on_path=$(command -v git 2>/dev/null || true)
+ if [ -n "$_git_on_path" ]; then _git_candidates+=("$_git_on_path"); fi
+ _git_candidates+=(/opt/homebrew/bin/git /usr/local/bin/git /usr/bin/git)
+
+ for _git_path in "${_git_candidates[@]}"; do
+ [ -x "$_git_path" ] || continue
+ # macOS ships a /usr/bin/git launcher even before the Command Line
+ # Tools exist. Calling that launcher may open an unrelated system
+ # dialog, so skip it and keep probing Homebrew's off-PATH locations.
+ if [ "$(uname -s 2>/dev/null || true)" = 'Darwin' ] &&
+ [ "$_git_path" = '/usr/bin/git' ] && command -v xcode-select >/dev/null 2>&1 &&
+ ! xcode-select -p >/dev/null 2>&1; then
+ continue
+ fi
+ "$_git_path" --version >/dev/null 2>&1 || continue
+ _git_dir=${_git_path%/*}
+ case ":$PATH:" in
+ *":$_git_dir:"*) ;;
+ *) PATH="$_git_dir:$PATH"; export PATH ;;
+ esac
+ return 0
+ done
+ return 1
}
refresh_prerequisite_state() {
@@ -205,7 +219,7 @@ missing_prerequisite_labels() {
}
has_install_tty() {
- [ -r /dev/tty ] && [ -w /dev/tty ]
+ { : </dev/tty; } 2>/dev/null && { : >/dev/tty; } 2>/dev/null
}
detect_prerequisite_manager() {
diff --git a/tests/unit/install/test_installer_flow.py b/tests/unit/install/test_installer_flow.py
index 6b1fc1ac79..2cf3d1fd25 100644
--- a/tests/unit/install/test_installer_flow.py
+++ b/tests/unit/install/test_installer_flow.py
@@ -59,7 +59,12 @@ def test_installer_prompts_only_inside_missing_prerequisite_flow() -> None:
ps1_outside = ps1[:ps1_begin] + ps1[ps1_end:]
assert "Read-Host" not in ps1_outside
assert "$Host.UI.Prompt" not in ps1
- assert ps1[ps1_begin:ps1_end].count("Read-Host") == 2
+ ps1_prompt_lines = [
+ line
+ for line in ps1[ps1_begin:ps1_end].splitlines()
+ if "Read-Host" in line and not line.lstrip().startswith("#")
+ ]
+ assert len(ps1_prompt_lines) == 2
for forbidden in ("input(", "Confirm.ask", "Prompt.ask", "getpass"):
assert forbidden not in py
diff --git a/tests/unit/install/test_prerequisite_bootstrap.py b/tests/unit/install/test_prerequisite_bootstrap.py
index bc0da061ea..cfc1ab3284 100644
--- a/tests/unit/install/test_prerequisite_bootstrap.py
+++ b/tests/unit/install/test_prerequisite_bootstrap.py
@@ -9,8 +9,10 @@ re-check, and return ready to the same installer process.
from __future__ import annotations
+import os
import shutil
import subprocess
+import sys
from pathlib import Path
import pytest
@@ -41,11 +43,19 @@ def _find_bash() -> str | None:
return None
-POWERSHELL = shutil.which("pwsh") or shutil.which("powershell")
+POWERSHELLS = tuple(
+ dict.fromkeys(
+ executable
+ for name in ("pwsh", "powershell")
+ if (executable := shutil.which(name)) is not None
+ )
+)
BASH = _find_bash()
-def _run_powershell_flow(tmp_path: Path, *, initially_ready: bool) -> str:
+def _run_powershell_flow(
+ tmp_path: Path, *, powershell: str, initially_ready: bool
+) -> str:
driver = r"""
$ErrorActionPreference = 'Stop'
$PrerequisiteMode = 'auto'
@@ -111,7 +121,7 @@ Write-Output $summary
path = tmp_path / "driver.ps1"
path.write_text(driver, encoding="utf-8")
result = subprocess.run(
- [POWERSHELL, "-NoProfile", "-File", str(path)],
+ [powershell, "-NoProfile", "-File", str(path)],
capture_output=True,
text=True,
timeout=30,
@@ -189,18 +199,55 @@ printf 'READY=%s;INSTALLS=%s;ITEMS=%s;STATES=%s\n' \
return result.stdout.strip()
[email protected](POWERSHELL is None, reason="PowerShell is not available")
[email protected]("powershell", POWERSHELLS or (None,))
@pytest.mark.parametrize("initially_ready", [True, False])
def test_powershell_rechecks_and_continues_in_same_process(
- tmp_path: Path, initially_ready: bool
+ tmp_path: Path, powershell: str | None, initially_ready: bool
) -> None:
- out = _run_powershell_flow(tmp_path, initially_ready=initially_ready)
+ if powershell is None:
+ pytest.skip("PowerShell is not available")
+ out = _run_powershell_flow(
+ tmp_path, powershell=powershell, initially_ready=initially_ready
+ )
if initially_ready:
assert out == "READY=True;INSTALLS=0;ITEMS=;STATES=1"
else:
assert out == "READY=True;INSTALLS=1;ITEMS=python,git;STATES=2"
[email protected]("powershell", POWERSHELLS or (None,))
+def test_powershell_probes_a_real_python_without_nested_quote_breakage(
+ tmp_path: Path, powershell: str | None
+) -> None:
+ """Windows PowerShell 5 strips some nested native-command quotes."""
+ if powershell is None:
+ pytest.skip("PowerShell is not available")
+ driver = r"""
+$ErrorActionPreference = 'Stop'
+$PrerequisiteMode = 'never'
+$InitialPath = $env:Path
+function Write-Ok { param([string]$Text) }
+function Write-Note { param([string]$Text) }
+function Write-Err { param([string]$Text) }
+__BLOCK__
+$probe = Test-PythonCandidate $env:JARVIS_TEST_PYTHON
+if ($null -eq $probe) { throw 'real Python probe returned null' }
+Write-Output "FOUND=$($probe.Compatible);VERSION=$($probe.Version)"
+""".replace("__BLOCK__", _block(INSTALL_PS1))
+ path = tmp_path / "real-python-probe.ps1"
+ path.write_text(driver, encoding="utf-8")
+ env = dict(os.environ, JARVIS_TEST_PYTHON=sys.executable)
+ result = subprocess.run(
+ [powershell, "-NoProfile", "-File", str(path)],
+ env=env,
+ capture_output=True,
+ text=True,
+ timeout=30,
+ )
+ assert result.returncode == 0, result.stderr or result.stdout
+ assert result.stdout.strip().startswith("FOUND=True;VERSION=3.")
+
+
@pytest.mark.skipif(BASH is None, reason="Bash is not available")
@pytest.mark.parametrize("initially_ready", [True, False])
def test_posix_rechecks_and_continues_in_same_process(
@@ -226,3 +273,6 @@ def test_posix_covers_established_native_package_managers() -> None:
source = INSTALL_SH.read_text(encoding="utf-8")
for manager in ("Homebrew", "apt-get", "dnf", "yum", "zypper", "pacman", "apk"):
assert manager in source
+ # A curl-piped macOS shell may not have Homebrew's prefix on PATH yet.
+ assert "/opt/homebrew/bin/git" in source
+ assert "/usr/local/bin/git" in source