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:06)

Ruben Lütkeef5c690d6b3a
diff --git a/install/install.ps1 b/install/install.ps1
index 24618fcb53..ae1a033641 100644
--- a/install/install.ps1
+++ b/install/install.ps1
@@ -4,8 +4,8 @@
# irm https://raw.githubusercontent.com/PersonalJarvis/PersonalJarvis/main/install/install.ps1 | iex
#
# This bootstrap is intentionally small. It:
-# 1. Verifies Python 3.11+ is available.
-# 2. Verifies git is available.
+# 1. Verifies Python 3.11+ and git are available.
+# 2. Offers to install either missing prerequisite, then re-checks in place.
# 3. Checks for Node.js 18+ (optional - a missing Node never blocks the install).
# 4. Clones (or updates) personal-jarvis into ~\.personal-jarvis.
# 5. Creates a Python venv, installs `rich` + `packaging`.
@@ -66,7 +66,7 @@ $GoldDeep╚█████╔╝██║ ██║██║ ██║ ╚█
$GoldDeep ╚════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═══╝ ╚═╝╚══════╝$Rst
$Dim P E R S O N A L J A R V I S · talk to your computer$Rst
-$Dim Installs the full profile · asks nothing · launches when done$Rst
+$Dim Checks prerequisites · installs the full profile · launches when done$Rst
"@
Write-Host $art
}
@@ -84,75 +84,283 @@ Write-Banner
$RepoUrl = if ($env:JARVIS_INSTALL_REPO) { $env:JARVIS_INSTALL_REPO } else { 'https://github.com/PersonalJarvis/PersonalJarvis.git' }
$Branch = if ($env:JARVIS_INSTALL_REF) { $env:JARVIS_INSTALL_REF } else { 'main' }
$InstallDir = if ($env:JARVIS_INSTALL_DIR) { $env:JARVIS_INSTALL_DIR } else { Join-Path $env:USERPROFILE '.personal-jarvis' }
+$PrerequisiteMode = if ($env:JARVIS_INSTALL_PREREQS) { $env:JARVIS_INSTALL_PREREQS.ToLowerInvariant() } else { 'ask' }
+$InitialPath = $env:Path
# Forward any extra args to installer.py (e.g. --no-launch, --dry-run, --with-voice-local)
$ExtraArgs = $args
+# --- prerequisite-bootstrap begin ------------------------------------------
+# This block stays shell-native because Python may not exist yet. Tests extract
+# it directly and exercise the retry/continuation state machine with fakes.
function Test-Tool {
- param([string]$Name, [string]$VersionArg = '--version')
+ param([string]$Name, [string[]]$VersionArgs = @('--version'))
try {
- $out = & $Name $VersionArg 2>&1
- return @{ Found = $true; Version = ($out | Select-Object -First 1) }
+ $out = & $Name @VersionArgs 2>&1
+ $code = $LASTEXITCODE
+ if ($null -eq $code) { $code = 0 }
+ return @{
+ Found = ($code -eq 0)
+ Version = [string]($out | Select-Object -First 1)
+ }
} catch {
return @{ Found = $false; Version = $null }
}
}
-function Test-PythonVersion {
+function Test-PythonCandidate {
param([string]$Exe)
- $check = Test-Tool $Exe
- if (-not $check.Found) { return $false }
- # Match X.Y where X >= 3 and Y >= 11
- if ($check.Version -match 'Python\s+(\d+)\.(\d+)\.\d+') {
+ try {
+ $out = & $Exe -c 'import sys; print("%d.%d.%d" % sys.version_info[:3])' 2>&1
+ if ($LASTEXITCODE -ne 0) { return $null }
+ $version = [string]($out | Select-Object -First 1)
+ if ($version -notmatch '^(\d+)\.(\d+)\.(\d+)$') { return $null }
$major = [int]$Matches[1]
$minor = [int]$Matches[2]
- return ($major -gt 3) -or ($major -eq 3 -and $minor -ge 11)
+ return [pscustomobject]@{
+ Exe = $Exe
+ Version = $version
+ Compatible = (($major -gt 3) -or ($major -eq 3 -and $minor -ge 11))
+ }
+ } catch {
+ return $null
}
- return $false
}
-# ----------------------------------------------------------------- preflight
-Write-Phase '1/6' 'Prerequisites'
+function Find-CompatiblePython {
+ $candidates = @()
+ if ($env:JARVIS_PYTHON) {
+ # An explicit pin is authoritative: never silently substitute another
+ # interpreter for the one the user selected.
+ $candidates += $env:JARVIS_PYTHON
+ } else {
+ $candidates += @('python', 'python3', 'py')
+ $patterns = @()
+ if ($env:LOCALAPPDATA) {
+ $patterns += Join-Path $env:LOCALAPPDATA 'Programs\Python\Python*\python.exe'
+ }
+ if ($env:ProgramFiles) {
+ $patterns += Join-Path $env:ProgramFiles 'Python*\python.exe'
+ }
+ foreach ($pattern in $patterns) {
+ $candidates += @(Get-ChildItem -Path $pattern -File -ErrorAction SilentlyContinue |
+ Sort-Object FullName -Descending | Select-Object -ExpandProperty FullName)
+ }
+ }
+
+ $closest = $null
+ $seen = @{}
+ foreach ($candidate in $candidates) {
+ if (-not $candidate) { continue }
+ $key = $candidate.ToLowerInvariant()
+ if ($seen[$key]) { continue }
+ $seen[$key] = $true
+ $probe = Test-PythonCandidate $candidate
+ if ($null -eq $probe) { continue }
+ if ($probe.Compatible) {
+ return [pscustomobject]@{
+ Found = $true
+ Exe = $probe.Exe
+ Version = $probe.Version
+ Closest = $closest
+ }
+ }
+ if ($null -eq $closest) { $closest = $probe }
+ }
+ return [pscustomobject]@{
+ Found = $false
+ Exe = $null
+ Version = $null
+ Closest = $closest
+ }
+}
-# Python: try `python` first, then `py -3.11`, then `py -3`.
-$pythonExe = $null
-$pythonVer = $null
-foreach ($candidate in @('python', 'py')) {
- if (Test-PythonVersion $candidate) {
- $pythonExe = $candidate
- $info = Test-Tool $candidate
- if ($info.Version -match '(Python\s+\d+\.\d+\.\d+)') { $pythonVer = $Matches[1] } else { $pythonVer = $candidate }
- break
+function Get-PrerequisiteState {
+ $python = Find-CompatiblePython
+ $gitCheck = Test-Tool 'git'
+ return [pscustomobject]@{
+ Python = $python
+ GitFound = $gitCheck.Found
+ GitVersion = $gitCheck.Version
+ Ready = ($python.Found -and $gitCheck.Found)
}
}
-if (-not $pythonExe) {
- Write-Err 'Python 3.11+ not found.'
- # Honesty over a bare "not found": name any too-old interpreter we saw, so
- # a user staring at a working `python --version` understands the verdict
- # (3.8 reads "bigger" than 3.11 unless you know Python's version ordering).
- $reported = @{}
- foreach ($candidate in @('python', 'py')) {
- $info = Test-Tool $candidate
- if ($info.Found -and $info.Version -match 'Python\s+(\d+\.\d+\.\d+)' -and -not $reported[$Matches[1]]) {
- $reported[$Matches[1]] = $true
- Write-Note "Closest match: Python $($Matches[1]) (via '$candidate') - too old: Jarvis needs 3.11+,"
- Write-Note 'and Python versions count 3.8 < 3.9 < 3.10 < 3.11.'
+
+function Write-PrerequisiteState {
+ param($State, [switch]$ShowMissing)
+ if ($State.Python.Found) {
+ Write-Ok "Python $($State.Python.Version) ($($State.Python.Exe))"
+ } elseif ($ShowMissing) {
+ Write-Err 'Python 3.11+ not found.'
+ if ($null -ne $State.Python.Closest) {
+ Write-Note "Closest match: Python $($State.Python.Closest.Version) via '$($State.Python.Closest.Exe)' - too old."
+ Write-Note 'Python versions count 3.8 < 3.9 < 3.10 < 3.11.'
}
}
- Write-Note 'Install it from https://www.python.org/downloads/ then re-run this command.'
- Write-Note '(After install, open a NEW PowerShell window so PATH refreshes.)'
- exit 1
+ if ($State.GitFound) {
+ Write-Ok $State.GitVersion
+ } elseif ($ShowMissing) {
+ Write-Err 'git not found.'
+ }
+}
+
+function Get-MissingPrerequisiteLabels {
+ param($State)
+ $missing = @()
+ if (-not $State.Python.Found) { $missing += 'Python 3.12 (satisfies 3.11+)' }
+ if (-not $State.GitFound) { $missing += 'Git' }
+ return $missing
+}
+
+function Request-PrerequisiteConsent {
+ param([string[]]$Missing)
+ switch ($PrerequisiteMode) {
+ 'auto' {
+ Write-Note 'Automatic prerequisite installation was enabled by JARVIS_INSTALL_PREREQS=auto.'
+ return $true
+ }
+ 'never' { return $false }
+ 'ask' { }
+ default {
+ Write-Err "Invalid JARVIS_INSTALL_PREREQS value '$PrerequisiteMode'. Use ask, auto, or never."
+ return $false
+ }
+ }
+
+ if (-not [Environment]::UserInteractive) {
+ Write-Note 'This shell cannot ask for consent. Re-run interactively or set JARVIS_INSTALL_PREREQS=auto.'
+ return $false
+ }
+ Write-Note "Missing required software: $($Missing -join ', ')."
+ Write-Note 'Jarvis can install it with WinGet, wait for completion, and continue this same run.'
+ Write-Note 'Continuing also accepts the package and WinGet source agreements for these packages.'
+ try {
+ $answer = Read-Host ' Install the missing prerequisites now? [Y/n]'
+ } catch {
+ return $false
+ }
+ return ([string]::IsNullOrWhiteSpace($answer) -or $answer -match '^(?i:y|yes)$')
+}
+
+function Refresh-ProcessPath {
+ $machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
+ $userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
+ $env:Path = ((@($InitialPath, $userPath, $machinePath) |
+ Where-Object { $_ }) -join ';')
}
-Write-Ok "$pythonVer"
-# Git
-$gitCheck = Test-Tool 'git'
-if (-not $gitCheck.Found) {
- Write-Err 'git not found.'
- Write-Note 'Install from https://git-scm.com/download/win then re-run this command.'
+function Invoke-PrerequisitePackage {
+ param([string]$PackageId, [string]$Label)
+ Write-Note "installing $Label (this may open one Windows approval prompt)"
+ $output = & winget install --id $PackageId --exact --source winget --silent `
+ --disable-interactivity --accept-source-agreements --accept-package-agreements 2>&1
+ $code = $LASTEXITCODE
+ if ($code -ne 0) {
+ Write-Err "$Label installation did not complete (WinGet exit $code)."
+ @($output | Select-Object -Last 8) | ForEach-Object { Write-Note ([string]$_) }
+ return $false
+ }
+ Write-Ok "$Label installer completed"
+ return $true
+}
+
+function Invoke-MissingPrerequisiteInstall {
+ param($State)
+ $wingetCheck = Test-Tool 'winget'
+ if (-not $wingetCheck.Found) {
+ Write-Err 'WinGet is not available, so Jarvis cannot install the prerequisites automatically.'
+ return $false
+ }
+ $installOk = $true
+ if (-not $State.Python.Found) {
+ if (-not (Invoke-PrerequisitePackage 'Python.Python.3.12' 'Python 3.12')) {
+ $installOk = $false
+ }
+ }
+ if (-not $State.GitFound) {
+ if (-not (Invoke-PrerequisitePackage 'Git.Git' 'Git')) {
+ $installOk = $false
+ }
+ }
+ return $installOk
+}
+
+function Wait-ForPrerequisites {
+ param([int]$Seconds = 10)
+ $attempts = [Math]::Max(1, [int][Math]::Ceiling($Seconds / 2.0))
+ $state = $null
+ for ($i = 0; $i -lt $attempts; $i++) {
+ Refresh-ProcessPath
+ $state = Get-PrerequisiteState
+ if ($state.Ready) { return $state }
+ if ($i -lt ($attempts - 1)) { Start-Sleep -Seconds 2 }
+ }
+ return $state
+}
+
+function Write-ManualPrerequisiteHelp {
+ param($State)
+ if (-not $State.Python.Found) {
+ Write-Note 'Python: https://www.python.org/downloads/windows/'
+ }
+ if (-not $State.GitFound) {
+ Write-Note 'Git: https://git-scm.com/download/win'
+ }
+}
+
+function Ensure-Prerequisites {
+ $state = Get-PrerequisiteState
+ Write-PrerequisiteState $state -ShowMissing
+ if ($state.Ready) { return $state }
+ if ($env:JARVIS_PYTHON -and -not $state.Python.Found) {
+ Write-Note "JARVIS_PYTHON is pinned to '$($env:JARVIS_PYTHON)' and is not a compatible interpreter."
+ Write-Note 'Update or unset that pin before prerequisite installation.'
+ return $null
+ }
+
+ $missing = @(Get-MissingPrerequisiteLabels $state)
+ if (-not (Request-PrerequisiteConsent $missing)) {
+ Write-ManualPrerequisiteHelp $state
+ Write-Note 'Nothing was installed. Run this command again after adding the prerequisites.'
+ return $null
+ }
+
+ [void](Invoke-MissingPrerequisiteInstall $state)
+ $state = Wait-ForPrerequisites
+
+ 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) {
+ return $null
+ }
+ try {
+ $answer = Read-Host ' Finish any manual installer, then press Enter to re-check; R retries WinGet, Q stops'
+ } catch {
+ return $null
+ }
+ if ($answer -match '^(?i:q|quit)$') { return $null }
+ if ($answer -match '^(?i:r|retry)$') {
+ [void](Invoke-MissingPrerequisiteInstall $state)
+ }
+ $state = Wait-ForPrerequisites
+ }
+
+ Write-PrerequisiteState $state
+ return $state
+}
+# --- prerequisite-bootstrap end --------------------------------------------
+
+# ----------------------------------------------------------------- preflight
+Write-Phase '1/6' 'Prerequisites'
+
+$prerequisites = Ensure-Prerequisites
+if ($null -eq $prerequisites) {
+ Write-Err 'Prerequisite setup was not completed.'
exit 1
}
-Write-Ok 'git'
+$pythonExe = $prerequisites.Python.Exe
+$pythonVer = "Python $($prerequisites.Python.Version)"
# Node.js 18+ -- powers only the OPTIONAL Jarvis-Agent worker CLIs (Claude
# Code / Codex) that heavy missions delegate to, plus the Node-based
diff --git a/install/install.sh b/install/install.sh
index 644d9835ee..7382831fdc 100755
--- a/install/install.sh
+++ b/install/install.sh
@@ -5,8 +5,8 @@
# curl -fsSL https://raw.githubusercontent.com/PersonalJarvis/PersonalJarvis/main/install/install.sh | bash
#
# This bootstrap is intentionally small. It:
-# 1. Verifies Python 3.11+ is available.
-# 2. Verifies git is available.
+# 1. Verifies Python 3.11+ and git are available.
+# 2. Offers to install either missing prerequisite, then re-checks in place.
# 3. Checks for Node.js 18+ (optional - a missing Node never blocks the install).
# 4. Clones (or updates) personal-jarvis into ~/.personal-jarvis.
# 5. Creates a Python venv, installs `rich` + `packaging`.
@@ -20,6 +20,7 @@ set -euo pipefail
REPO_URL="${JARVIS_INSTALL_REPO:-https://github.com/PersonalJarvis/PersonalJarvis.git}"
BRANCH="${JARVIS_INSTALL_REF:-main}"
INSTALL_DIR="${JARVIS_INSTALL_DIR:-$HOME/.personal-jarvis}"
+PREREQUISITE_MODE="${JARVIS_INSTALL_PREREQS:-ask}"
# 24-bit brand palette (docs/BRAND.md): Signal Yellow on matte black, with the
# forged-gold wordmark gradient #FFE552 → #FFD60A → #B8960A. On a real terminal
@@ -58,7 +59,7 @@ ${GOLD_DEEP}╚█████╔╝██║ ██║██║ ██║ ╚
${GOLD_DEEP} ╚════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═══╝ ╚═╝╚══════╝${RST}
${DIM} P E R S O N A L J A R V I S · talk to your computer${RST}
-${DIM} Installs the full profile · asks nothing · launches when done${RST}
+${DIM} Checks prerequisites · installs the full profile · launches when done${RST}
EOF
# -------------------------------------------------------------- preflight
@@ -146,30 +147,281 @@ find_python() {
}
# --- python-detection end ---------------------------------------------------
-if ! find_python; then
- err 'Python 3.11+ not found.'
- if [ -n "$FOUND_TOO_OLD" ]; then
- note "Closest match: $FOUND_TOO_OLD - too old: Jarvis needs 3.11+,"
- note 'and Python versions count 3.8 < 3.9 < 3.10 < 3.11.'
+# --- prerequisite-bootstrap begin ------------------------------------------
+# 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
- note 'Install it from:'
- note ' - macOS: https://www.python.org/downloads/ or "brew install python"'
- note ' - Linux: your distro package (apt install python3.12, dnf install python3.12, ...)'
- note 'Then open a NEW terminal window and re-run this command.'
- note 'Python installed somewhere unusual? Pin it explicitly:'
- note ' curl -fsSL <this url> | JARVIS_PYTHON=/path/to/python3.12 bash'
- exit 1
-fi
-PY_VER=$("$PYTHON_EXE" -c 'import sys; print("Python %d.%d.%d" % sys.version_info[:3])' 2>/dev/null || echo "$PYTHON_EXE")
-ok "$PY_VER ($PYTHON_EXE)"
+ "$_git_path" --version >/dev/null 2>&1
+}
+
+refresh_prerequisite_state() {
+ PYTHON_EXE=""
+ if find_python; then PYTHON_READY=1; else PYTHON_READY=0; fi
+ if git_available; then GIT_READY=1; else GIT_READY=0; fi
+ if [ "$PYTHON_READY" -eq 1 ] && [ "$GIT_READY" -eq 1 ]; then
+ PREREQUISITES_READY=1
+ else
+ PREREQUISITES_READY=0
+ fi
+}
+
+write_prerequisite_state() {
+ _show_missing="${1:-0}"
+ if [ "$PYTHON_READY" -eq 1 ]; then
+ _py_ver=$("$PYTHON_EXE" -c 'import sys; print("Python %d.%d.%d" % sys.version_info[:3])' 2>/dev/null || printf '%s' "$PYTHON_EXE")
+ ok "$_py_ver ($PYTHON_EXE)"
+ elif [ "$_show_missing" -eq 1 ]; then
+ err 'Python 3.11+ not found.'
+ if [ -n "$FOUND_TOO_OLD" ]; then
+ note "Closest match: $FOUND_TOO_OLD - too old: Jarvis needs 3.11+."
+ note 'Python versions count 3.8 < 3.9 < 3.10 < 3.11.'
+ fi
+ fi
+ if [ "$GIT_READY" -eq 1 ]; then
+ _git_ver=$(git --version 2>/dev/null || printf 'git')
+ ok "$_git_ver"
+ elif [ "$_show_missing" -eq 1 ]; then
+ err 'git not found.'
+ fi
+}
+
+missing_prerequisite_labels() {
+ _missing=""
+ if [ "$PYTHON_READY" -eq 0 ]; then _missing='Python 3.11+'; fi
+ if [ "$GIT_READY" -eq 0 ]; then
+ if [ -n "$_missing" ]; then _missing="$_missing, Git"; else _missing='Git'; fi
+ fi
+ printf '%s' "$_missing"
+}
+
+has_install_tty() {
+ [ -r /dev/tty ] && [ -w /dev/tty ]
+}
+
+detect_prerequisite_manager() {
+ PREREQ_MANAGER=""
+ PREREQ_MANAGER_CMD=""
+ case "$(uname -s 2>/dev/null || printf unknown)" in
+ Darwin)
+ for _brew in "$(command -v brew 2>/dev/null || true)" /opt/homebrew/bin/brew /usr/local/bin/brew; do
+ if [ -n "$_brew" ] && [ -x "$_brew" ]; then
+ PREREQ_MANAGER='Homebrew'
+ PREREQ_MANAGER_CMD="$_brew"
+ return 0
+ fi
+ done
+ ;;
+ *)
+ for _manager in apt-get dnf yum zypper pacman apk; do
+ if command -v "$_manager" >/dev/null 2>&1; then
+ PREREQ_MANAGER="$_manager"
+ PREREQ_MANAGER_CMD="$_manager"
+ return 0
+ fi
+ done
+ ;;
+ esac
+ return 1
+}
+
+request_prerequisite_consent() {
+ _missing="$1"
+ case "$PREREQUISITE_MODE" in
+ auto)
+ note 'Automatic prerequisite installation was enabled by JARVIS_INSTALL_PREREQS=auto.'
+ return 0
+ ;;
+ never) return 1 ;;
+ ask) ;;
+ *)
+ err "Invalid JARVIS_INSTALL_PREREQS value '$PREREQUISITE_MODE'. Use ask, auto, or never."
+ return 1
+ ;;
+ esac
+ if ! has_install_tty; then
+ note 'This shell cannot ask for consent. Re-run interactively or set JARVIS_INSTALL_PREREQS=auto.'
+ return 1
+ fi
+
+ note "Missing required software: $_missing."
+ if [ -n "$PREREQ_MANAGER" ]; then
+ note "Jarvis can install it with $PREREQ_MANAGER, wait, and continue this same run."
+ note 'Continuing authorizes the package manager to accept the relevant package agreements.'
+ _prompt=' Install the missing prerequisites now? [Y/n] '
+ else
+ note 'No supported package manager was found; Jarvis can keep this run open while you install it.'
+ _prompt=' Show the manual path and keep checking this run? [Y/n] '
+ fi
+ printf '%s' "$_prompt" >/dev/tty
+ IFS= read -r _answer </dev/tty || return 1
+ case "$_answer" in ''|y|Y|yes|YES|Yes) return 0 ;; *) return 1 ;; esac
+}
+
+run_privileged() {
+ if [ "$(id -u)" -eq 0 ]; then
+ "$@"
+ elif command -v sudo >/dev/null 2>&1; then
+ sudo "$@"
+ else
+ note 'Administrator access is required, but sudo is unavailable.'
+ return 126
+ fi
+}
+
+install_with_prerequisite_manager() {
+ _python_ready="$1"
+ _git_ready="$2"
+ _log=$(mktemp "${TMPDIR:-/tmp}/jarvis-prerequisites.XXXXXX") || return 1
+ _result=1
+
+ case "$PREREQ_MANAGER" in
+ Homebrew)
+ _packages=()
+ if [ "$_python_ready" -eq 0 ]; then _packages+=(python); fi
+ if [ "$_git_ready" -eq 0 ]; then _packages+=(git); fi
+ if "$PREREQ_MANAGER_CMD" install "${_packages[@]}" >"$_log" 2>&1; then _result=0; fi
+ ;;
+ apt-get)
+ _packages=()
+ if [ "$_python_ready" -eq 0 ]; then _packages+=(python3 python3-venv); fi
+ if [ "$_git_ready" -eq 0 ]; then _packages+=(git); fi
+ if run_privileged env DEBIAN_FRONTEND=noninteractive apt-get update -qq >"$_log" 2>&1 &&
+ run_privileged env DEBIAN_FRONTEND=noninteractive apt-get install -y -qq "${_packages[@]}" >>"$_log" 2>&1; then
+ _result=0
+ fi
+ ;;
+ dnf|yum)
+ _packages=()
+ if [ "$_python_ready" -eq 0 ]; then _packages+=(python3); fi
+ if [ "$_git_ready" -eq 0 ]; then _packages+=(git); fi
+ if run_privileged "$PREREQ_MANAGER_CMD" -q -y install "${_packages[@]}" >"$_log" 2>&1; then _result=0; fi
+ ;;
+ zypper)
+ _packages=()
+ if [ "$_python_ready" -eq 0 ]; then _packages+=(python3); fi
+ if [ "$_git_ready" -eq 0 ]; then _packages+=(git); fi
+ if run_privileged zypper --non-interactive --quiet install "${_packages[@]}" >"$_log" 2>&1; then _result=0; fi
+ ;;
+ pacman)
+ _packages=()
+ if [ "$_python_ready" -eq 0 ]; then _packages+=(python); fi
+ if [ "$_git_ready" -eq 0 ]; then _packages+=(git); fi
+ if run_privileged pacman -Sy --noconfirm --needed "${_packages[@]}" >"$_log" 2>&1; then _result=0; fi
+ ;;
+ apk)
+ _packages=()
+ if [ "$_python_ready" -eq 0 ]; then _packages+=(python3 py3-pip); fi
+ if [ "$_git_ready" -eq 0 ]; then _packages+=(git); fi
+ if run_privileged apk add --no-progress "${_packages[@]}" >"$_log" 2>&1; then _result=0; fi
+ ;;
+ esac
+
+ if [ "$_result" -eq 0 ]; then
+ ok "$PREREQ_MANAGER finished installing prerequisites"
+ else
+ err "$PREREQ_MANAGER did not complete the prerequisite installation."
+ tail -n 12 "$_log" 2>/dev/null || true
+ fi
+ rm -f "$_log"
+ return "$_result"
+}
+
+start_manual_prerequisite_path() {
+ write_manual_prerequisite_help
+ if [ "$PYTHON_READY" -eq 0 ] &&
+ [ "$(uname -s 2>/dev/null || true)" = 'Darwin' ] && command -v open >/dev/null 2>&1; then
+ open 'https://www.python.org/downloads/macos/' >/dev/null 2>&1 || true
+ fi
+ if [ "$GIT_READY" -eq 0 ] &&
+ [ "$(uname -s 2>/dev/null || true)" = 'Darwin' ] && command -v xcode-select >/dev/null 2>&1; then
+ xcode-select --install >/dev/null 2>&1 || true
+ fi
+}
+
+write_manual_prerequisite_help() {
+ if [ "$PYTHON_READY" -eq 0 ]; then
+ note 'Python: https://www.python.org/downloads/'
+ note 'Linux: install Python 3.11+ plus its venv package from your distribution.'
+ fi
+ if [ "$GIT_READY" -eq 0 ]; then
+ note 'Git: https://git-scm.com/downloads'
+ fi
+}
+
+install_missing_prerequisites() {
+ detect_prerequisite_manager || true
+ if [ -z "$PREREQ_MANAGER" ]; then
+ start_manual_prerequisite_path
+ return 1
+ fi
+ note "installing prerequisites with $PREREQ_MANAGER"
+ install_with_prerequisite_manager "$PYTHON_READY" "$GIT_READY"
+}
+
+wait_for_prerequisites() {
+ _attempt=0
+ while [ "$_attempt" -lt 5 ]; do
+ hash -r
+ refresh_prerequisite_state
+ if [ "$PREREQUISITES_READY" -eq 1 ]; then return 0; fi
+ _attempt=$((_attempt + 1))
+ if [ "$_attempt" -lt 5 ]; then sleep 2; fi
+ done
+ return 1
+}
+
+ensure_prerequisites() {
+ refresh_prerequisite_state
+ write_prerequisite_state 1
+ if [ "$PREREQUISITES_READY" -eq 1 ]; then return 0; fi
+ if [ -n "${JARVIS_PYTHON:-}" ] && [ "$PYTHON_READY" -eq 0 ]; then
+ note "JARVIS_PYTHON is pinned to '$JARVIS_PYTHON' and is not a compatible interpreter."
+ note 'Update or unset that pin before prerequisite installation.'
+ return 1
+ fi
+
+ detect_prerequisite_manager || true
+ _missing=$(missing_prerequisite_labels)
+ if ! request_prerequisite_consent "$_missing"; then
+ write_manual_prerequisite_help
+ note 'Nothing was installed. Run this command again after adding the prerequisites.'
+ return 1
+ fi
+
+ install_missing_prerequisites || true
+ wait_for_prerequisites || true
+
+ while [ "$PREREQUISITES_READY" -eq 0 ]; do
+ err 'The required commands are still unavailable in this terminal.'
+ write_manual_prerequisite_help
+ if [ "$PREREQUISITE_MODE" = 'auto' ] || ! has_install_tty; then return 1; fi
+ printf '%s' ' Finish any manual installer, then press Enter to re-check; R retries, Q stops: ' >/dev/tty
+ IFS= read -r _answer </dev/tty || return 1
+ case "$_answer" in
+ q|Q|quit|QUIT|Quit) return 1 ;;
+ r|R|retry|RETRY|Retry) install_missing_prerequisites || true ;;
+ esac
+ wait_for_prerequisites || true
+ done
+
+ write_prerequisite_state 0
+ return 0
+}
+# --- prerequisite-bootstrap end --------------------------------------------
-if ! command -v git >/dev/null 2>&1; then
- err 'git not found.'
- note ' - macOS: install Xcode CLT ("xcode-select --install") or "brew install git"'
- note ' - Linux: your distro package (apt install git, ...)'
+if ! ensure_prerequisites; then
+ err 'Prerequisite setup was not completed.'
exit 1
fi
-ok 'git'
# Node.js 18+ — powers only the OPTIONAL Jarvis-Agent worker CLIs (Claude Code
# / Codex) that heavy missions delegate to, plus the Node-based marketplace